I am new to ruby on rails and have just installed active admin and was trying to customize the
views.
I have a product and image table. Each image belongs to one product.
Now I want to display a column with the associated image when showing the products page.
At the moment it´s only the image_url text which isn´t working. Later on I would like do
have the picture displayed in 50x50px.
How to I do this? (image model: name:string image_url:text)
Here is what I have done :
ActiveAdmin.register Product do
index do
column "Image" do |image|
image.image_url
end
column :name
column :preview_text
column :full_text
column :price, :sortable => :price do |product|
div :class => "price" do
number_to_currency product.price
end
end
default_actions
end
end
I dont know how to fix that part with " do image. I am a beginner in rails 2 days exp..
It seems the syntax is wrong and throwing error:
undefined method `image_url' for #<Product:0x00000101b5a458>
Thanks
image_tag product.image.image_url, size: "50x50"
without needing to deal with css. – Melee