設計給我一個相當困難的時間。目前,除了註冊重定向之外,其他一切似乎都在起作用。我想設計重定向到我的鎮控制器在索引行動,註冊或登錄(登錄實際工作)。註冊後重新設計
我試着重寫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