I am using the administration framework 'active admin' to build a RubyOnRails Application. I have a Dropdown Menu that looks like this in my form:
form do |f|
f.inputs do
f.input :art, as: :select, :include_blank => "Bitte wählen!", label: 'art', :collection => ["Fachobjekt", "Gruppe", "Externes Dokument"]
end
f.actions
end
Now in my controller I want to check the selected value. I tried:
controller do
after_save :update_object
def update_object(guid)
if params[:art].values == 'Fachobjekt'
# do stuff
end
end
end
I chose 'Fachobjekt' in my Dropdown but I get the NoMethodeError "undefined method 'values' for nil:NilClass"
, so the params[:art]
is null.
My question is: what is the correct syntax to get the selected value of my f.input-field? I appreciate any hint!
[:root_tables] ist the model name. I put it before [:art] like params[:root_tables][:art] but same error.
binding.pry
or similar. place it on the very top of method and see what params you are receiving. or Even simple print of them (actually rails are printing params on every request) post those params, then it might be easier to find reason – blazpie