ruby on rails - Get attribute of ActiveRecord by name -
i have partial, used in many places of project.
it renders items, related specified tag, like:
@tag.articles.each |a| # render articles end i need partial render not articles, other items, associated tags.
so, partial has 1 parameter association_name , looks this:
@tag[association_name].each |a| # render articles end i call partial in following ways:
# render articles render :partial => "items", :locals => {:association_name => "articles"} # render videos render :partial => "items", :locals => {:association_name => "videos"} # etc. the problem - cannot refer fields of article model in way:
@article[association_name] how , why does't works ?
@article.send(association_name)
Comments
Post a Comment