Ruby on Rails Monday, September 9, 2019

You can do @item.pictures << @picture

El mar., 10 sep. 2019 01:02, fugee ohu <fugee279@gmail.com> escribió:
class Item < ApplicationRecord
 has_many :pictures, as: :imageable
end

class Picture < ApplicationRecord
 belongs_to :imageable, polymorphic: true, optional: true
end

NoMethodError in PicturesController#create

undefined method `<<' for #<Picture:0x007f3758cc88f0>


@item.pictures.create << @picture

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1ad30bf7-4b54-49e7-86ab-8544049e567c%40googlegroups.com.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcBtHJWywOUZ80EVUPqa5WeQ69o6FOZ7hfQ3KrT9V_c5qQ%40mail.gmail.com.

No comments:

Post a Comment