Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Mass assignment is correct. You would create or update a model by passing <code>params[:your_models_name]</code> to <code>YourModel.new</code> or <code>YourModel.find(params[:id]).update_attributes params[:your_model]</code>. Strong parameters is a way to whitelist the params that can be mass assigned. </p> <p><a href="http://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html" rel="nofollow">From the guides:</a></p> <pre><code>class PeopleController &lt; ActionController::Base # Using "Person.create(params[:person])" would raise an # ActiveModel::ForbiddenAttributes exception because it'd # be using mass assignment without an explicit permit step. # This is the recommended form: def create Person.create(person_params) end # This will pass with flying colors as long as there's a person key in the # parameters, otherwise it'll raise an ActionController::MissingParameter # exception, which will get caught by ActionController::Base and turned # into a 400 Bad Request reply. def update redirect_to current_account.people.find(params[:id]).tap { |person| person.update!(person_params) } end private # Using a private method to encapsulate the permissible parameters is # just a good pattern since you'll be able to reuse the same permit # list between create and update. Also, you can specialize this method # with per-user checking of permissible attributes. def person_params params.require(:person).permit(:name, :age) end end </code></pre> <p>In the above example if the params that came in looked like this: </p> <pre><code>{ person: { name: 'bob', age: 30, admin: true } } </code></pre> <p>Then the <code>admin: true</code> param would not have been assigned to bob's Person.</p> <p>As for your input field format question, they should come in however they were on the form. Is this not the case for you?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload