I have a cgi_attributes
hstore type column in the UrlCommand model.
class UrlCommand < ActiveRecord::Base
store_accessor :cgi_attributes, :name, :range, :security, :default_value
end
However, the keys in cgi_attributes
should be dynamically added by users.
And I also want to render each key as a input filed in my form
Rather than hard-code the columns
- [:name, :range, :security].each do | column |
= render :partial => 'attributes' , :locals => { f: f, column: column }
And also need to add those dynamically generated key can be update into my Model.
def url_command_params
params.require(:url_command).permit(:model_name, :firmware_version, :cgi_attributes,
:cgi_name,:name, :range, :security)
end
Now, All of my code are based on hard-code, How to make the keys and value can be dynamically added by users and store into the UrlCommand model ?