Answer the question
In order to leave comments, you need to log in
rails. update_attributes is not executed, or is it executed, but strange?
Hello. Using devise, I want to update user from my controller. But everything is very strange.
routes.rb
get 'users/:id' => 'users#show', :as => :user
get 'edit' => 'users#edit'
patch "edit" => "users#update"
devise_for :users, :path => '', controllers: {
sessions: 'custom_sessions',
registrations: 'custom_registrations'
}, :path_names => { :sign_up => 'signup',
:sign_out => 'logout',
:sign_in => 'login',
:edit => nil }
resources :notes
root 'notes#index'
def edit
@user = current_user
end
def update
@user = User.find(current_user.id)
if @user.update_attributes(user_params)
flash[:notice] = "Profile successfully updated"
redirect_to root_path
else
render 'edit'
end
end
private
def user_params
params[:user].permit(:name)
end
-provide(:title, "#{@user.name}")
=form_for @user, url: edit_path, method: :patch do |f|
=f.text_field :name
=f.submit "update"
Answer the question
In order to leave comments, you need to log in
Most likely a validation error. By default, devise requires you to enter your current password to confirm changes.
Thank you all, all rashil! His own forgetfulness played a cruel joke.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question