Reputation: 41
I use Action Text and Action Storage. Rails make _blob.html.erb file:
`
`<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
<% if blob.representable? %>
<%= link_to (image_tag (blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]))), news_path(@new) %>
<% end %>
<figcaption class="attachment__caption">
<% if caption = blob.try(:caption) %>
<%= caption %>
<% else %>
<span class="attachment__name"><%= blob.filename %></span>
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
<% end %>
</figcaption>
</figure>``
In 4 line I link_to for images.All images displays on index page for path /news (model name is new). I want to see show page when I press link. But I don't know how to make @new object to create /news/id path. I understand I need make @new object in index action. Now I make @new object in index action like this:
def index
@news = News.all
@new = News.first
end
But All images have same id and when I click to links I go same show view. Where and how I need make @new objects?
I dont't try anything because I don't know to think.
Upvotes: 0
Views: 23