Link to home
Start Free TrialLog in
Avatar of terencepires
terencepires

asked on

Define a render action with params

Hello there,

i'm trying to set a render action for an index page, it works fine without parameters but i can't seem to set some correctly.

i would like the render to call the list method with the parameters artist_cat = 1

that would be the equivalent of this : "list?artist_cat=1"

any ideas ?
class Admin::ArtistsController < ApplicationController
  
  layout "admin"
  
  before_filter :check_authentication
  
  def index
    list
    render :action => 'list', :artist_cat => '0'
  end
 
  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }
 
  def list
    #@artist_pages, @artists = paginate :artists, :per_page => 10
    @artists = Artist.find(:all, :conditions => ["artist_cat = ?", params[:artist_cat]], :order => "name")
    #@artists = Artist.find(:all, :order => "artist_cat, name")
  end

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Andrew Doades
Andrew Doades
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of terencepires
terencepires

ASKER

:)