i have the following form
<%= simple_form_for(@software) do |f| %>
<%= f.input :softwarename, :collection => software_options, as: :check_boxes %>
And this helper.
module SoftwareHelper
def software_options
['7zip','SysInternals','Office','PDF-Creator']
end
end
My application controller looks like this
def software_params
params.require(:software).permit(:softwarename => [])
end
And here is my software controller:
def new
@software = Software.new
end
def create
@software = Software.new(software_params)
@software.save
redirect_to @software
end
When I try to save the form input to my database (sqllite) i get the following error:
TypeError: can't cast Array to string
Do i have to convert the array to a string?
collectionoption will make the data come through as an array. So you will need to convert this array to whatever form you store the data in the database, which you don't specify. How are you actually storing it?