Ruby on Rails
Wednesday, February 7, 2018
On Wednesday, February 7, 2018 at 12:38:57 PM UTC-5, Colin Law wrote:
On 7 February 2018 at 17:19, fugee ohu <fuge...@gmail.com> wrote:I dunno why this doesn't produce any output<% @pictures=Picture.all %>Model.all has been deprecated since rails 2.3.8. Don't use it.<% @pictures.all do |picture| %>this should be using each, not allColin<% if @person %><% if picture.person_id == @person.id %><%= check_box_tag 'person[picture_ids][]', picture.id, true %><% else %><%= check_box_tag 'person[picture_ids][]', picture.id %><% end %><%= image_tag picture.name.thumb %><% end %><% end %>
I can use <% if picture.person_id == @person.id %> ? This is a has_many_through relationship Person has_many :pictures, through: :person_pictures and also Picture has_many :people, through: :person_pictures What's the right syntax to test if the picture is already associated to the person when iterating through pictures Also if I can't use Model.all in a routine I can still use it to get @pictures=Picture.all right?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8d160a04-6951-4159-bfa7-8eee046cb3c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment