Note that there are some explanatory texts on larger screens.

plurals
  1. POStrong parameters - Devise 3.0.0 and Rails 4. "Unpermitted parameters: name"
    primarykey
    data
    text
    <p>I am currently using Rails 4 and Devise 3.0.0. I have tried to add a custom field of "Name" to the sign up form and edit registration form. Whenever I submit the form, the following errors arise:</p> <pre><code>Unpermitted parameters: name WARNING: Can't mass-assign protected attributes for User: email, password, password_confirmation. </code></pre> <p>I understand that this has something to do with the way Rails 4 handles parameters, but I do not understand what I am supposed to do about it right now. I have searched around and have seen that I am supposed to add some lines to a User model involving "params."</p> <p>My user model currently looks like this:</p> <pre><code>class User &lt; ActiveRecord::Base devise :database_authenticatable, :registerable, #:recoverable, :rememberable, :trackable, :validatable attr_accessible :name, :password, :password_confirmation, :remember_me, :email end </code></pre> <p>According to <a href="https://stackoverflow.com/questions/17371334/how-is-attr-accessible-used-in-rails-4">How is attr_accessible used in Rails 4?</a>, I am supposed to add the following code to "The controller." </p> <pre><code>class PeopleController &lt; ApplicationController def create Person.create(person_params) end private def person_params params.require(:person).permit(:name, :age) end end </code></pre> <p>What controller? And is this literal code? Since I am dealing with User, do I have to use User.create(user_params)? instead of Person.create(person_params)?</p>
    singulars
    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.
    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