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

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -