设计给我一个相当困难的时间。目前,除了注册重定向之外,其他一切似乎都在起作用。我想设计重定向到我的镇控制器在索引行动,注册或登录(登录实际工作)。注册后重新设计
我试着重写RegistrationsController,我已经尝试添加一个applicationsController功能,如:
def after_sign_in_path_for(resource_or_scope)
if resource_or_scope.is_a?(User)
town_path
else
super
end
end
不过,我得到了同样的错误:
NoMethodError in User/townController#index
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.*
认真,我无法找到一种方法来做到这一点。请有任何想法吗? :)
编辑:MY ROUTES
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session GET /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /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 /(.:format) {:action=>"index", :controller=>"home"}
user_root /user(.:format) {:action=>"index", :controller=>"user/town"}
home /home(.:format) {:action=>"index", :controller=>"home"}
town /town(.:format) {:action=>"index", :controller=>"town"}
inbox /messages(.:format) {:action=>"index", :controller=>"messages"}
inbox /messages/inbox(.:format) {:action=>"inbox", :controller=>"messages"}
的routes.rb:
devise_for :users
root :to => "home#index"
namespace :user do
root :to => "town#index"
end
scope :path => '/home', :controller => :home do
match '/' => :index, :as => 'home'
end
scope :path => '/town', :controller => :town do
match '/' => :index, :as => 'town'
end
......
显示我们通过`$耙routes`请 – raidfive 2011-02-14 00:17:17
感谢名单的路线,我添加了相关的路线 – Spyros 2011-02-14 00:23:27
向我们展示你的routes.rb内的色器件指令。从外观来看,资源不是用户。找出它实际上是哪个类。 – Dex 2011-02-14 01:33:40