0

i would like to know if this is possible

ex:

in my Users controller

i have the edit and update method for the users#edit users/edit_acc view for update their pass and email

but i would like that the users create, edit and update their localization attributes like adress, city and etc on the same controller and view folder but with different view html

so this look like this users#edit_loc users/edit_loc

and as everytime that the user gonna create/update their attr, look like that just the update and edit methods are allowed for this.

thanks :)

Ex:

UserController

def edit
        @user = User.find_by_auth_token!(cookies[:auth_token]) 
     end

     def update
       @user = User.find_by_auth_token!(cookies[:auth_token])

       respond_to do |format|
         if @user.update_attributes(params[:user])
         format.html { render action: "edit" }
         flash[:success] = 'Conta Atualizada'


       else
         format.html { render action: "edit" }
         format.json { render json: @user.errors, status: :unprocessable_entity }
     end
   end
 end







 def edit_loc
        @user = User.find_by_auth_token!(cookies[:auth_token]) 
     end

     def update_loc
       @user = User.find_by_auth_token!(cookies[:auth_token])

       respond_to do |format|
         if @user.update_attributes(params[:user])
         format.html { render action: "edit_loc" }
         flash[:success] = 'Conta Atualizada'


       else
         format.html { render action: "edit_loc" }
         format.json { render json: @user.errors, status: :unprocessable_entity }
     end
   end
 end
1
  • please add a code sample of what youre trying to do there, obviously english isnt your strong suit so atleast make yourself clear in the language everyone understands here :> Commented Feb 9, 2012 at 21:51

1 Answer 1

3

Just add the appropriate entries in config/routes.rb:

resources :users do
  get :edit_loc
  put :update_loc
end

Then create the view and add the actions to your controller.

Sign up to request clarification or add additional context in comments.

3 Comments

thank you very much Tom and sorry Benjamin. just one doubt Tom, i never change the methods edit and update for edit_loc and update_loc on controller?
You are using the regular edit and update methods strictly for updating email and passwords, correct? So then you want to add two new methods to two new actions to the controller for location updates, edit_loc and update_loc. Is that what you are asking?
no srry, just the same method for different action. because, everytime that try to edit and update the users_loc still requesting just the update action instead of the update_loc. anyway thank you very much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.