ruby - Rails: Active Admin Association Image column -
i new ruby on rails , have installed active admin , trying customize
views.
i have product , image table. each image belongs 1 product.
now want display column associated image when showing products page.
at moment it´s image_url text isn´t working. later on do
have picture displayed in 50x50px.
how this? (image model: name:string image_url:text)
here have done :
activeadmin.register product index column "image" |image| image.image_url end column :name column :preview_text column :full_text column :price, :sortable => :price |product| div :class => "price" number_to_currency product.price end end default_actions end end
i dont know how fix part " image. beginner in rails 2 days exp..
it seems syntax wrong , throwing error:
undefined method `image_url' #<product:0x00000101b5a458>
thanks
you need image_url
image object product.image.image_url
.
regarding image size, can display image size want, so
column "image" |product| image_tag product.image.image_url, class: 'my_image_size' end
.css
.my_image_size { width: 50px; height: 50px; }
or can resize image itself, gem such carrierwave.
Comments
Post a Comment