I am working through Michael Hartl's railstutorial. My problem is /user/1/edit renders perfectly, but using edit_user_path(current_user) doesn't.
I've checked for typos, done some searching, found this seemed like it might be the same issue, but the answer didn't get my link working. Right now, I am trying to diff my code with Michael's.
Let me know if there's anything other code that would help. Thanks for taking the time to read my question.
output of rake routes:
$ bundle exec rake routes
Prefix Verb URI Pattern Controller#Action
password_resets_new GET /password_resets/new(.:format) password_resets#new
password_resets_edit GET /password_resets/edit(.:format) password_resets#edit
account_activations_edit GET /account_activations/edit(.:format) account_activations#edit
root GET / static_pages#home
help GET /help(.:format) static_pages#help
about GET /about(.:format) static_pages#about
contact GET /contact(.:format) static_pages#contact
signup GET /signup(.:format) users#new
login GET /login(.:format) sessions#new
POST /login(.:format) sessions#create
logout DELETE /logout(.:format) sessions#destroy
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
edit_account_activation GET /account_activations/:id/edit(.:format) account_activations#edit
password_resets POST /password_resets(.:format) password_resets#create
new_password_reset GET /password_resets/new(.:format) password_resets#new
edit_password_reset GET /password_resets/:id/edit(.:format) password_resets#edit
password_reset PATCH /password_resets/:id(.:format) password_resets#update
PUT /password_resets/:id(.:format) password_resets#update
microposts POST /microposts(.:format) microposts#create
micropost DELETE /microposts/:id(.:format) microposts#destroy
added relevant log entry.
Started GET "/edit_user_path(current_user)" for 76.186.33.24 at 2014-12-11 13:59:32 +0000
ActionController::RoutingError (No route matches [GET] "/edit_user_path(current_user)"): web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:22:in
middleware_call'call' actionpack (4.2.0.beta2) lib/action_dispatch/middleware/show_exceptions.rb:30:in
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:13:incall' railties (4.2.0.beta2) lib/rails/rack/logger.rb:38:incall_app' railties (4.2.0.beta2) lib/rails/rack/logger.rb:20:inblock in call' activesupport (4.2.0.beta2) lib/active_support/tagged_logging.rb:68:inblock in tagged'
activesupport (4.2.0.beta2) lib/active_support/tagged_logging.rb:26:intagged' activesupport (4.2.0.beta2) lib/active_support/tagged_logging.rb:68:intagged' railties (4.2.0.beta2) lib/rails/rack/logger.rb:20:incall' actionpack (4.2.0.beta2) lib/action_dispatch/middleware/request_id.rb:21:incall' rack (1.6.0.beta) lib/rack/methodoverride.rb:22:incall'call' activesupport (4.2.0.beta2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in
rack (1.6.0.beta) lib/rack/runtime.rb:17:incall' rack (1.6.0.beta) lib/rack/lock.rb:17:incall' actionpack (4.2.0.beta2) lib/action_dispatch/middleware/static.rb:103:incall'call' railties (4.2.0.beta2) lib/rails/engine.rb:514:in
rack (1.6.0.beta) lib/rack/sendfile.rb:113:incall' railties (4.2.0.beta2) lib/rails/application.rb:161:incall' rack (1.6.0.beta) lib/rack/tempfile_reaper.rb:15:incall' rack (1.6.0.beta) lib/rack/lint.rb:49:in_call' rack (1.6.0.beta) lib/rack/lint.rb:37:incall' rack (1.6.0.beta) lib/rack/showexceptions.rb:24:incall' rack (1.6.0.beta) lib/rack/commonlogger.rb:33:incall' rack (1.6.0.beta) lib/rack/chunked.rb:54:incall' rack (1.6.0.beta) lib/rack/content_length.rb:15:incall' rack (1.6.0.beta) lib/rack/handler/webrick.rb:89:inservice'
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:inservice'run'
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'Rendered /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates/rescues/_trace.html.erb (1.6ms) Rendered /usr/local/rvm/gems/ruby-2.1.1@rails4/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates/rescues/routing_error.html.erb within rescues/layout (37.1ms) 76.186.33.24 - - [11/Dec/2014:13:59:32 +0000] "GET /500 HTTP/1.1" 500 1477 0.0647
routes.rb
Rails.application.routes.draw do get 'password_resets/new' get 'password_resets/edit' get 'account_activations/edit' root 'static_pages#home' get 'help' => 'static_pages#help' get 'about' => 'static_pages#about' get 'contact' => 'static_pages#contact' get 'signup' => 'users#new' get 'login' => 'sessions#new' post 'login' => 'sessions#create' delete 'logout' => 'sessions#destroy' resources :users resources :account_activations, only: [:edit] resources :password_resets, only: [:new, :create, :edit, :update] resources :microposts, only: [:create, :destroy] end_header.html.erb
<header class="navbar navbar-fixed-top navbar-inverse"> <div class="container"> <%= link_to "sample app", root_path, id: "logo" %> <nav> <ul class="nav navbar-nav pull-right"> <li><%= link_to "Home", root_path %></li> <li><%= link_to "Help", help_path %></li> <% if logged_in? %> <li><%= link_to "Users", users_path %></li> <li class="dropdown"> <a href='#' class="dropdown-toggle" data-toggle="dropdown"> Account <b class="caret"></b> </a> <ul class="dropdown-menu"> <li><%= link_to "Profile", current_user %></li> <li><%= link_to "Settings", 'edit_user_path(current_user)' %></li> <li class="divider"></li> <li> <%= link_to "Log out", logout_path, method: "delete" %> </li> </ul> </li> <% else %> <li><%= link_to "Log in", login_path %></li> <% end %> </ul> </nav> </div> </header>
rake routesin console. - rmagnum2002edit_user_path(current_user)should not be in string as you have it in your code - rmagnum2002<%= link_to "Settings", edit_user_path(current_user) %>, I don't see any other problem that might brake it. - rmagnum2002