ruby - Rails - How can I display one nested attributes (Solved) -
I have a new problem, I create a web where I have uploaded several indexes, using nested attributes and polymorphic tables By doing, I want to show only one image .html in my index, but I do not know how. But I am new to the rail
photography RB
class photography & lt; ActiveRecord :: Base Valid: Title ,: Description, Attendance: True_key: User has_many: as images, as: imageable, dependent: delete accepts_nested_attributes_for: images ,: reject_if = & gt; Lambda {| One | A [: img_str] .blank? } ,: Allow_destroy = & gt; True end
image.rb
class image & lt; ActiveRecord :: Base is_to: imageable, polymorphic: correct mount_uploader: img_str, AssetUploader end
index.html.erb
& lt;% of photos For @ photo% & gt; & Lt;% = link_to photo.title, photography_path (photo)% & gt; & Lt;% photo.images.each do | Picture | & Gt%; & Lt;% = images.img_str% & gt; & Lt;% end% & gt; & Lt;% end% & gt;
For the method I show all the image, try adding the first add, but for the first 5 the undefined method says: Fixnum.
I think I would make a helpful method, but I'm not sure. Can somebody help me out?. Thanks
Try:
In addition, in Ruby, little is used for instead: & lt;% @ photos.each do | Picture | & Gt%;
Comments
Post a Comment