[Rails] Share partial among different resources
I am trying to render a file from Subject resource in a User resource
view. I am getting error:
undefined method `each' for nil:NilClass. Apparently @subject is nil
but not sure how to fix this...
Here is User resourve view (users/show.html.erb)
<%= render 'subjects/index' %>
Here is subjects_controller
def show
@subject = Subject.find(params[:id])
...
end
Here is subjects/index.html.erb (The file I want to render)
<% @subjects.each do |subject| %>
<tr>
<td class="hilite_list">
<a href="/books/index_books/<%= subject.id %>"><%=
subject.title %> (<%= subject.questions.count %>)</a>
</td>
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home