I have a partial, that will be used in many places of a project.
It renders items, related to specified tag, like:
@tag.articles.each do |a|
# render articles
end
I need this partial to render not only articles, but any other items, associated with tags.
So, this partial has one parameter association_name and looks like this:
@tag[association_name].each do |a|
# render articles
end
I call this partial in following ways:
# to render articles
render :partial => "items", :locals => {:association_name => "articles"}
# to render videos
render :partial => "items", :locals => {:association_name => "videos"}
# etc.
The problem is - i cannot refer fields of Articl开发者_JAVA技巧e model in a way:
@article[association_name]
How to do it and why it does't works ?
@article.send(association_name)
精彩评论