Created
May 4, 2010 11:13
-
-
Save narfdotpl/389282 to your computer and use it in GitHub Desktop.
ror: "/profile" instead of "/users/1/edit"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h1 edit your profile | |
- form_for @user, :url => {:action => :update} do |form| | |
%div= form.text_field :name | |
= error_message_on @user, :name, 'name ' | |
%div= submit_tag 'save' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionController::Routing::Routes.draw do |map| | |
map.root :controller => 'tasks' | |
map.resources :tasks | |
map.with_options :controller => :users do |u| | |
u.edit_user '/profile', :action => :edit, :conditions => {:method => :get} | |
u.update_user '/profile', :action => :update | |
end | |
map.connect ':controller/:action/:id' | |
map.connect ':controller/:action/:id.:format' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
redirect_to edit_user_url#(@current_user) | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
before_filter :signin_required | |
def edit | |
@user = User.find(current_user) | |
end | |
def update | |
@user = User.find(current_user) | |
if @user.update_attributes(params[:user]) | |
redirect_to root_path | |
else | |
render :edit | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment