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

@tazsingh I prefer to keep ...

49de4cd2f26705785cbef2b15a9df7aa Talk
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')} } }
...

Ruby On DRY up a controller action

by Nick, August 05, 2011 11:51

@tazsingh suggested using #...

49de4cd2f26705785cbef2b15a9df7aa Talk
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

by Nick, August 05, 2011 11:13, 6 refactorings, tagged with rails, ruby, controller, DRY

Any suggestions for DRYing ...

49de4cd2f26705785cbef2b15a9df7aa Talk

Ruby On Condensing nested conditionals

by Nick, November 12, 2008 17:56

Interesting solution, Adam!...

49de4cd2f26705785cbef2b15a9df7aa Talk

Ruby On Condensing nested conditionals

by Nick, November 12, 2008 00:40

Hi Adam. You're correct abo...

49de4cd2f26705785cbef2b15a9df7aa Talk
class PropertiesController < ApplicationController
  before_filter :authorise_action
...

Ruby Condensing nested conditionals

by Nick, November 11, 2008 21:28, 4 refactorings, tagged with ruby rails condense conditions

The code below works, but f...

49de4cd2f26705785cbef2b15a9df7aa Talk

Ruby On DRY up a controller action

by Nick, November 03, 2008 05:46

Hey Adam. There's a Propert...

49de4cd2f26705785cbef2b15a9df7aa Talk

Ruby On DRY up a controller action

by Nick, November 01, 2008 17:10

Thanks Jarkko. The action's...

49de4cd2f26705785cbef2b15a9df7aa Talk
filename    = 'process.log'
ids         = {}
...

Bash On Groupping with stats

by Nick, November 01, 2008 16:57 Star_fullStar_full

I'd write a small script fo...

49de4cd2f26705785cbef2b15a9df7aa Talk
# GET /neighbourhoods/map_filter
def map_filter
  @map_filter_errors  = nil # Stores errors related to a filter request.
...

Ruby DRY up a controller action

by Nick, October 31, 2008 20:52, 5 refactorings, tagged with rails fat controller

My Neighbourhood "map_filte...

49de4cd2f26705785cbef2b15a9df7aa Talk
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...

49de4cd2f26705785cbef2b15a9df7aa Talk
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...

by Nick, October 24, 2008 20:03, 2 refactorings, tagged with process rails form

In my Rails app, the Proper...

49de4cd2f26705785cbef2b15a9df7aa Talk