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
def create
    @lead = Lead.new(params[:lead])
    @contact = @lead.contact_detail = ContactDetail.new(params[:contact_detail])
...

Ruby Best way to do this

by https://www.google.com/accounts/o8/id?id=AItOawl-DJ5xgYVFKrrLOGZqwCiGLkx38LeB1cU, April 28, 2011 00:08, 6 refactorings, tagged with controller, rails3

Thanks

55502f40dc8b7c769880b10874abc9d0 Talk
def search
    @search = params[:company_search]
    @results = Company.search @search, :include => :staff_id,
...

Ruby Messy if statements

by https://www.google.com/accounts/o8/id?id=AItOawkXhagloEt9LaGYb5TnfYmraHmMC8fzlsE, March 22, 2011 00:55, 2 refactorings, tagged with rails, controller, sphinx

This works but it's messy. ...

6b0e4504e14e6b9e239ffd1dc20f301c Talk
def create
  allow_publish = logged_in? && @trend.allow_more_publishers?(params[:connection_id])
  if allow_publish && !@trend.include_publisher?(params[:connection_id])
...

Ruby what if I don't like too ma...

by edgarjs, October 21, 2010 15:50, 4 refactorings, tagged with rails, conditions, associations, controller, create, build, ifs

I want to avoid the abuse o...

380f2ee82510287050b118947e8526dd Talk
def create
    @announcement =  current_account.announcements.build(params[:announcement])
    
...

Ruby Re-Refactor Mailer Conditions

by fnjord.myopenid.com, February 13, 2009 17:44, 2 refactorings, tagged with rails, ruby, conditions, controller, mailer

This is just a mess. It wou...

321bbdb120165eebbaf37e781d4ec71b Talk
class PeopleController < ApplicationController

...

Ruby Re-use code for new and cre...

by Dave, November 05, 2008 09:30, 4 refactorings, tagged with rails, dry, controller

Hello,

I have a 'people'...

997adc3b63a05bf75f833c48fa246e19 Talk
if @foo.update_attributes(params[:foo]) and @foo.bar.update_attributes(params[:bar])
      redirect_to foo_url(@parent)
    else
...

Ruby Saving multiple models in o...

by rafeco, July 29, 2008 15:56, 2 refactorings, tagged with rails, activerecord, controller

What's the best way to save...

Df2e97f18b5802e199d4920552a52d34 Talk