I have a partial one that will be used in many places of the project.
It displays elements related to the specified tag, for example:
@tag.articles.each do |a|
end
I need this partial to display not only articles, but also any other elements related to tags.
So, this partial one has a connection_name parameter and looks like this:
@tag[association_name].each do |a|
end
I call it partial as follows:
render :partial => "items", :locals => {:association_name => "articles"}
render :partial => "items", :locals => {:association_name => "videos"}
The problem is that I cannot refer to the article model fields in this way:
@article[association_name]
How to do it and why it doesn’t work?
source
share