Reputation: 1167
I am doing a site using activeadmin. I have set up all the necessary fields up and set the form up with paperclip set up. My fields work for other resources and my model for the resource is set up.
When I add a new resource into the back in activeadmin I can save it but I get fields empty when you view it in the backend. The model is set up right too.
Model:
class Spotlight < ActiveRecord::Base
has_attached_file :image, styles: {
large: "600x450#",
medium: "250x250#",
small: "100x100#"
}, :default_url => "/images/:style/filler.png"
end
activeadmin Spotlight.rb
ActiveAdmin.register Spotlight do
form do |f|
f.inputs do
f.input :video
f.input :image
f.input :description
end
f.buttons
end
controller do
def permitted_params
params.permit(:spotlights => [:video, :image, :description])
end
end
end
ID 8 DESCRIPTION EMPTY VIDEO EMPTY IMAGE image
Is this a common issue found?
Cheers
Upvotes: 0
Views: 1335
Reputation: 1986
The params you receive from the form are in params[:spotlight] not in params[:spotlights] (notice the extra 's'). If it's not a typo in the post that should make sure the params are not filtered by strong_paramterers.
You can configure strong parameters to throw an exception when parameters get filtered out (advisable at least in development environment in my opinion). Otherwise you can find the messages in the log.
config.action_controller.action_on_unpermitted_parameters = :raise
Upvotes: 2