I am pretty new at this, so any help is much appreciated.
While building a tabbed interface I am trying to reuse the same partial and controller and pass a :conditions to a controller to build every tab differently.
@wishes_category = Wish.find :all,
:order => 'id DESC',
:conditions => {:user_id => @current_user.id}
First tab would need something like :category_id=>1 in the controller’s :conditions thus limiting what I show in it.
I am trying to pass this condition to a partial which would use the a pre-limited @wishes_category with :category_id=>1
Thanks!
Naz
==
Based on what Erik said, I then limited the @wishes_category this way
<% if category_id == wish.category_id %> in the partial thus solving the problem
You can pass local parameters to a partial through its render tag using something like:
This sets a local variable in the partial named
category_idequal to 1. In your partial, it would be referenced simply using<%= category_id %>. Now you are able to render the same partial file multiple times in a page with different local variables.Of course the variable
category_idmust exist in the partial before being used or it will throw an error. You can protect against this by checking<% if local_assigns[:category_id] %>first.