in my index.html.erb i'd like to save my settings to the database.
My settings are stored here
<%= javascript_tag do %>
window.settings = <%= raw Setting.where("shopify_domain = '#{@currentShop.domain}'").to_json %>
<% end %>
Now i'd like to write back my settings to the database by calling this function
function writeSettings() {
alert(settings[0].id); //this is working
<%= Setting.update(settings[0].id, :appearance => 'box') %> //not working unknown variable settings
}
How can i update my record?
Or, how can i call this function with parameters in my settings.rb file
# PATCH/PUT /settings/1
# PATCH/PUT /settings/1.json
def update
respond_to do |format|
if @setting.update(setting_params)
format.html { redirect_to @setting, notice: 'Setting was successfully updated.' }
format.json { render :show, status: :ok, location: @setting }
else
format.html { render :edit }
format.json { render json: @setting.errors, status: :unprocessable_entity }
end
end
end