with this below (a post has many blog_images and blog_image belongs to
<% @posts.each do |post| %>
<div class="FeatureItem"> <a href=""><img src="/images/<%=
post.blog_images.image_file_name %>" width=“220” height=“174” alt=""
style=“top: 27px; left: 13px;” />Click Here
<div class="FeatureContent"> <h2><a href=""><%= post.title %></a></h2> <p><%= post.body %></p> <p class="posted"><%= post.user_id %></p> </div> </div>
<% end %>
I get undefined method image_file_name because image_file_name is a
field in blog_images table. So activerecord generates field names as
instance methods but above I’m trying to use it as a class method, so
since there is no class method image_file_name in BlogImage class, it
throws error. Is there a way that I can get image_file_name without
creating a class mehtod because I want to pull the data dynamically from
the table, where the image file belongs to blog post.
Thanks for response.