I’m making a Rails app where I have a method:
def updateAttributes_post
if logged_in?
userPlucky = User.where(:screen_name=>session[:screen_name]).all
userPlucky.each do | user |
user.update_attributes(:email => params[:emailAddr], :password=>params[:passwordStr])
if user.save
flash[:success] = "Succesfully updated attributes!"
redirect_to '/dashboard'
else
errors = Array.new()
for i in 0..user.errors.full_messages.count
errors.push(user.errors.full_messages[i])
end
session[:error] = errors
flash[:error] = "Error saving"
redirect_to '/update'
end
end
else
redirect_to root_path
end
end
which is called on a POST request. The thing is on every if I’m redirecting on both cases, but I’m still getting a Template not found`. If I add a template with the name it asks it just renders the blank template without doing nothing. What I’m doing wrong?
If no user matches (ie
userPluckyis empty), you do not call anyredirect_to.