Ruby on Rails
Wednesday, February 7, 2018
On Wednesday, February 7, 2018 at 1:01:02 PM UTC-5, Colin Law wrote:
On 7 February 2018 at 17:51, fugee ohu <fuge...@gmail.com> wrote:
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?Model.all is deprecated, don't use it.If Picture has_many people then you can't use picture.person_id as one picture is associated with many people. so @picture.people is (effectively) an array of people. You will have determine whether the array includes that person.Colin--
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-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@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
Thanks, yea that's what I meant How do I test for the inclusion of picture in @person.pictures If I can't use Model.all how do I select all pictures from the pictures table?
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/45dcd144-63d7-47c8-b92f-e842dd4d0bdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment