"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!
Yes; the update action is just a default provided to make REST-based interfaces trivially easy. You will want to make sure you have a POST route in config/routes. Rb that references users#another_method_to_update presuming you're doing all this in the UsersController (and on Rails 3) but the basic answer to your question is that model operations (including updating fields) can be done anywhere you have the model available.
Up vote 0 down vote favorite share g+ share fb share tw.
For example in my users controller I already have an update method for other parts of my users account. I need a separate one for changing my users password. Is it possible to have something like this: def another_method_to_update user = User.
Authenticate(current_user. Email, params:current_password) if user. Update_attributes(params:user) login user format.
Js { render :js => "window. Location = '#{settings_account_path}'" } flash:success = "Password updated" else format. Js { render :form_errors } end end Then have my change password form know to use that method to perform the update?
It has 3 fields: current password new password confirm new password and I use ajax to show the form errors. Kind regards ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-3.1 link|improve this question edited Jan 13 at 13:43shime65211 asked Jan 13 at 11:00LondonGuy727210 100% accept rate.
Sure, you can have any number of methods to update/delete/edit whatever you like. You'll need to define their routes though. – Wahaj Ali Jan 13 at 11:16.
Yes; the update action is just a default provided to make REST-based interfaces trivially easy. You will want to make sure you have a POST route in config/routes. Rb that references users#another_method_to_update presuming you're doing all this in the UsersController (and on Rails 3) but the basic answer to your question is that model operations (including updating fields) can be done anywhere you have the model available.
There's no tying between what model methods can be called and what controller methods are being invoked.
Stick with the convention, use the default route. If I understood correctly, your page contains a form for password update. We could write entire code for this in the update method, but this is cleaner and more self-explanatory: def update change_password and return if change_password?
# old code of your update method # ... end private def change_password?! Params:current_password. Nil?
End def change_password user = User. Authenticate(current_user. Email, params:current_password) respond_to do |format| if user.
Update_attributes(params:user) login user flash:success = "Password updated" format. Js { render :js => "window. Location = '#{settings_account_path}'" } else format.
Js { render :form_errors } end end end This is a lot easier to understand for someone who will look at your code since you're still calling update method to update your model which then performs custom action. I've also fixed your custom method code.
In config/routes. Rb: puts "users/other_update_method.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.