Topic: this should be an easy one...

How can I refactor this?

        if tag.blank?
            @tabs = Tab.paginate(
                    :per_page => 50,
                    :page => params[:page],
                    :include => [:artist, :genre, :tuning],
                    :conditions => conditions,
                    :order => sortable_order('listing', :model => Artist, :field => 'name', :sort_direction => :asc)
                    )
        else
            @tabs = Tab.paginate(
                    Tab.find_tagged_with(tag),
                    :per_page => 50,
                    :page => params[:page],
                    :include => [:artist, :genre, :tuning],
                    :conditions => conditions,
                    :order => sortable_order('listing', :model => Artist, :field => 'name', :sort_direction => :asc)
                    )
        end

Re: this should be an easy one...

maybe something like this ?

options = {:per_page => 50,
           :page => params[:page],
           :include => [:artist, :genre, :tuning],
           :conditions => conditions,
           :order => sortable_order('listing', :model => Artist, :field => 'name', :sort_direction => :asc)}
@tabs = tag.blank? ? @tabs = Tab.paginate(options) : Tab.paginate(Tab.find_tagged_with(tag), options)

Re: this should be an easy one...

just correcting a little error:

options = {:per_page => 50,
           :page => params[:page],
           :include => [:artist, :genre, :tuning],
           :conditions => conditions,
           :order => sortable_order('listing', :model => Artist, :field => 'name', :sort_direction => :asc)}
@tabs = tag.blank? ? Tab.paginate(options) : Tab.paginate(Tab.find_tagged_with(tag), options)

Re: this should be an easy one...

oh yeah I copy pasted and forgot to delete it.
Thanks for correcting my mistake smile