My User model is as follows (user.rb)
class User < ActiveRecord::Base
validates :password, presence: true, length: { minimum: 6 }
validates :password_confirmation, presence: true
has_secure_password
validates(:name, presence: true, length: {maximum: 50})
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates(:email, presence: true,format: { with: VALID_EMAIL_REGEX }, uniqueness: true)
end
My UsersController is as follows (users_controller.rb)
class UsersController < ApplicationController
def new
end
private
def user_params
params.require(:user).permit(:name)
end
end
So I should only be able to mass-update(mass-assign) the name attribute only.
But when I logon to rails console and type the following command
user=User.find(1)
user.update_attributes(name: "ck",email: "ck@gmail.com", password: "ckck9090", password_confirmation: "ckck9090")
user.save
I am still able to update email.
I didn't mention the :email attributes in the strong parameter .permit(). So how can I still mass-update the email attribute?
Am I missing something?