I have a list of user emails in a bit of Javascript code in my view that I have created for my action. The view is in haml format. I want to press a submit button on a form and access this list of emails in the same action or another action.
I've tried using form_tag, form_for and just normal html forms, however I keep running into different issues. I've also tested with link_to and button_to tags.
Here's what we have for the Action:
module RailsAdmin
module Config
module Actions
class BulkProperties < RailsAdmin::Config::Actions::Base
RailsAdmin::Config::Actions.register(self)
register_instance_option :collection do
true
end
register_instance_option :http_methods do
[:get, :put]
end
register_instance_option :controller do
proc do
@all_users = User.all
@all_properties = UserProperty.all
@all_roles = Role.all
binding.pry
if request.get? # EDIT
respond_to do |format|
format.html { render @action.template_name }
format.js { render @action.template_name, layout: false }
end
elsif request.put? # UPDATE
binding.pry #Just testing this
end
end
register_instance_option :link_icon do
'icon-lock'
end
end
end
end
end
And this the part of my view giving me issues:
%form
.multiselect-form
.wrapper{"data-children-count" => "1"}
%select.collection{:multiple => "multiple", :id => "multi"}
%hr/
%h1 List of user properties
-@all_properties.each do |prop|
%input{:name => prop.name+"checkbox", :type => "checkbox", :id => prop.name+"checkbox"}
#{prop.name}
%input{:name => prop.name, :type => "text", :id => prop.name}
%br
%input{:name => "submit", :type => "submit", :formaction => 'http://localhost:3000/admin/user/bulk_properties?Application=8&Company=1&locale=en', :method => 'put'}
%br/
%br/
The outcome is that I am led to a CanCan issue where I'm getting 'You are not authorized...'. This is because the url actually ends up holding the parameters and so it tries to redirect me to a webpage that doesn't exist.