I have a simple_form_for
(I can also use simple_form
if easiest) that I want to pass/update 3 params. 1 of them is "user-generated", while 2 others needs to be insert/update in db "automatically".
Here is my current form:
= simple_form_for @request do |f|
= f.collection_select :partner_id, @partners, :id, :full_name, {prompt: "Select a user"}
= f.input :successful_ad, checked: true, value: true
= f.input :status, checked: false, value: 0
= f.submit "I have excepted"
What I am looking for is user can choose a :partner_id
from collection_select
, while I need to insert/update :successful_ad => true
and :status => false
.
I don't want to use hidden_field since it can be manipulated and safest way is to process them in background.
PS: reason I can't pass these params in edit/update actions is since I have this form in show action and is separated.
Sure, the safest way to always use server side code for it. But you need to know when it has to happen, and this is something that comes from client end.
You can use after_save
or after_update
, and can do the work there. But not every save
or update
action would need this; only a few may need this. So you need to have a hidden field in your form, and but you can encrypt the content of that, and then, on server side, you can do the certain task in your callback if you received that encrypted key.
An end user would always have the power to change the contents of hidden field, so now it's up to you to use an encrypted key, and a column name that a user wouldn't be able to break through.
Edit: for what you asked, you can do following:
= f.input :status, :input_html => { :checked => false, value: 'Your desired value'}