Brian Ambielli
Brian Ambielli

Reputation: 601

Partial locals are not being passed

I'm trying to pass some locals into a partial render in rails, however they are not getting passed.

<%=render :partial => "search_results", :locals => {:refinement => "all", :query => params[:search]}%>

The partial is being rendered in a view that has the param[:search] in it, that params[:search] is accessable inside of the partial without it being passed in as a local.

I'm trying to access the locals refinement and query by doing params[:refinement] and params[:query] inside of the partial, however they are not being recognized.

Upvotes: 0

Views: 184

Answers (2)

pungoyal
pungoyal

Reputation: 1798

Access them as locals[:refinement] or locals[:query] inside your partial. That should work.

Upvotes: 0

sevenseacat
sevenseacat

Reputation: 25049

You don't access them via params - you just access the local variable, eg. refinement or query.

Upvotes: 2

Related Questions