friendly id - Rails friendly_id gem mass assignment issue -


i using "friendly_id 4.0.0" gem making url user friendly.

below user model

user.rb model  class user < activerecord::base   extend friendlyid   friendly_id :name , :use => [:slugged,:history]   attr_accessible :email, :lname, :name   end 

below user_controller.rb file

@user = user.new(params[:user])  respond_to |format|   if @user.save     format.html { redirect_to @user, notice: 'user 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 getting can't mass-assign protected attributes: slug exception. try adding slug attr_accessible attr_accessible :email, :lname, :name, :slug still getting same error.

attr_accessible :email, :lname, :name   

attr_accessible protect mass-assignment

if try following work

@user = user.new(params[:user]) @user.email = params[:user][:email] respond_to |format|   if @user.save 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -