respond_to do |format|
if @image.update_attributes params[:product_image]
format.js { render :json => { :status => 'success', :data => {:message => I18n.t('product_image.actions.updated')} } }
...
Ruby On DRY up a controller action
by Nick,
August 05, 2011 12:42
if @image.update_attributes params[:product_image]
respond_to do |format|
format.json { render :json => { :status => 'success', :data => {:message => I18n.t('product_image.actions.updated')} } }
...
if @image.update_attributes params[:product_image]
if request.xhr?
render :json => { :status => 'success', :data => {:message => I18n.t('product_image.results.reordered')} }
...
Ruby DRY up a controller action
Any suggestions for DRYing ...
Ruby On Condensing nested conditionals
by Nick,
November 12, 2008 17:56
Interesting solution, Adam!...
Ruby On Condensing nested conditionals
by Nick,
November 12, 2008 00:40
Hi Adam. You're correct abo...
class PropertiesController < ApplicationController before_filter :authorise_action ...
Ruby Condensing nested conditionals
The code below works, but f...
# GET /neighbourhoods/map_filter def map_filter @map_filter_errors = nil # Stores errors related to a filter request. ...
Ruby DRY up a controller action
My Neighbourhood "map_filte...
class PropertyFilter < ActiveRecord::BaseWithoutTable attr_accessible :price_direction, :price # ...many more attributes... ...
Ruby On DRYing/shortening form proc...
by Nick,
October 30, 2008 17:25
Hey Adam, thanks for the re...
def self.filter_price(direction, price)
return nil if direction.blank? or price.blank?
return {:error => 'Invalid argument: direction'} unless ['at most', 'at least'].include? direction
...
Ruby DRYing/shortening form proc...
In my Rails app, the Proper...

@tazsingh I prefer to keep ...