I am using "friendly_id 4.0.0" gem for making url user friendly.
below is my user model
user.rb model
class User < ActiveRecord::Base
extend FriendlyId
friendly_id :name , :use => [:slugged,:history]
attr_accessible :email, :lname, :name
end
below is my user_controller.rb file
@user = User.new(params[:user])
respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render json: @user, status: :created, location: @user }
else
format.html { render action: "new" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
But I am getting Can't mass-assign protected attributes: slug exception.
I also try adding slug to attr_accessible as attr_accessible :email, :lname, :name, :slug
But still getting same error.