Rails 3.1 + Devise: The default routes for Devise aren't working -
i'm getting following error when try access "sign in" route (get /users/sign_in)...
no route matches {:action=>"home", :controller=>"devise/pages"} here's full error server log...
started "/users/sign_in" 127.0.0.1 @ 2012-06-05 00:51:54 -0700 processing devise::sessionscontroller#new html rendered devise/shared/_links.erb (2.9ms) rendered devise/sessions/new.html.erb within layouts/application (33.5ms) rendered pages/_header.html.erb (75.9ms) completed 500 internal server error in 349ms actionview::template::error (no route matches {:action=>"home", :controller=>"devise/pages"}): here's body of application/layout...
<!-- begin body --> <body class="top"> <!-- begin .container --> <div class="container"> <%= render 'pages/header' %> <%= render 'pages/menu' %> <p class="notice"><%= notice %></p> <p class="alert"><%= alert %></p> <%= yield %> <!-- end .container --> </div> <%= render 'pages/footer' %> </body> the controller have "pages" controller. also, here's route.rb file...
myapp::application.routes.draw devise_for :users match '/contact', :to => 'pages#contact' match '/news', :to => 'pages#news' match '/home', :to => 'pages#home' match '/features', :to => 'pages#features' root :to => 'pages#home' end i don't know if has it, generated views using rails generate devise:views command.
why trying access nonexistent "devise/pages" controller , "home" action when /users/sign_in? that's not routes show when rake routes...
new_user_session /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"} user_session post /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"} destroy_user_session delete /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"} user_password post /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"} new_user_password /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"} edit_user_password /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"} put /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"} cancel_user_registration /users/cancel(.:format) {:action=>"cancel", :controller=>"devise/registrations"} user_registration post /users(.:format) {:action=>"create", :controller=>"devise/registrations"} new_user_registration /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"} edit_user_registration /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"} put /users(.:format) {:action=>"update", :controller=>"devise/registrations"} delete /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"} root / {:controller=>"pages", :action=>"home"} contact /contact(.:format) {:controller=>"pages", :action=>"contact"} news /news(.:format) {:controller=>"pages", :action=>"news"} home /home(.:format) {:controller=>"pages", :action=>"home"} features /features(.:format) {:controller=>"pages", :action=>"features"} thanks in advance wisdom!
edit adding "pages/menu" partial request...
<!-- begin .menu-primary --> <div class="menu-primary"> <table> <tr> <td class="menu"> <ul> <li> <a href="/news">news</a> </li> <li> <a href="/features"><span>shop products</span></a> <ul> <li><a href="/features">features</a></li> </ul> </li> <li><a href="#"><span>shop parts</span></a><ul><li><a href="#">controls (coming soon)</a></li><li><a href="#">monitors (coming soon)</a></li><li><a href="#">artwork (coming soon)</a></li><li><a href="#">accessories (coming soon)</a></li></ul></li> <li><a href="/contact">contact us</a></li> </ul> </td> </tr> </table> <!-- end .menu-primary --> </div> update in header template, had...
<%= link_to image_tag("mylogo.png", :alt=>"", :width=>"300", :height=>"100"), {:action => 'home', :controller => 'pages'} %> and removing allows sign_in page load successfully. why?!
when constructing url {:action => 'home', :controller => 'pages'}, rails uses paths relative controller rendering current view. sign-in page, "devise/sessions", hence looks pagescontroller in devise namespace.
you can fix adding backslash specify controller in root, not within devise namespace.
replace:
{:action => 'home', :controller => 'pages'} with this:
{:action => 'home', :controller => '/pages'}
Comments
Post a Comment