ruby on rails - How to use an array to use Paperclip's photo.url method? -


the app:
application has many buses. each bus has many photos of interior , exterior. some of interior photos have associated image indicates location on bus photos taken (like "you here" marker on map), assigned through :parent_id attribute corresponds "parent" photos id.

the goal:
output url "child" image if selected photo "parent," , keep blank if not.

the problem:
way know how find particular associated image brings array. unfortunately me, photo.url method comes paperclip can't work array.

this closest want, but, again, brings array can't use find image url.

def assigned_floorplan(where pass in parent images params)   bus_images.all(conditions: { is_floorplan: true, parent_id: params.id }) end 

is dead end, or there way pull out id of associated image array can use photo.url method? or going wrong way? i'm willing approach problem totally differently if have suggestions.

you have call photo.url method each image separately. nested loop work:

<% @parent_images.each |parent_image| %>    <%= parent_image.photo.url %>    <% parent_image.child_images.each |child_image| %>     <%= child_image.photo.url %>   <% end %>  <% end %> 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -