ruby on rails - Access attributes of another model in view -
i have controller (of model aa) , in
def view_name end and model b with:
def attributes { :a => 'xyz'; } end how access attribute :a inside view of controller a, can display value of attribute :a in view page?
more info: model b has attribute :a url image , have display image through view of controller a. i'm wondering how use in <img> tag. <img src="<%= b.a %>" />. wouldn't have define b.a instance variable in controller use first? or there way?
normally if access attribute through instance of model b.
something should work in view:
<% b.each |test| %> <p><%= test.a %></p><br/> <% end %> this show of each instance of b attribute a
but if nice if add context easier you.
Comments
Post a Comment