Reputation: 5073
I want to render @users with different classes from different views. Trying to pass a class as a string into the partial:
<%= render @users, :locals=>{:style=> "col-sm-2 col-xs-12"} %>
And then in the partial:
<div class="<%= style %>">
But this is giving an error:
undefined local variable or method `style'
How can I implement this?
Upvotes: 1
Views: 441
Reputation: 1359
It should work if you write it as: <%= render @users, style: "col-sm-2 col-xs-12" %>
If you use :locals
, you can't use the shorthand method and would have to write out the entire render call like the docs say and would look like <%= render partial: "users", locals: { users: @users, style: "col-sm-2 col-xs-12" } %>
.
Upvotes: 1