【问题标题】:Rails devise not working for rails 3.2.1 on localhostRails 设计不适用于 localhost 上的 rails 3.2.1
【发布时间】:2013-01-20 18:30:13
【问题描述】:

我按照本教程中讨论的设计在我的本地主机上工作的每一步 - http://www.slideshare.net/wleeper/devise-and-rails upto page 8 of 22 我期待与第 8 页中提到的相同的用户登录表单,但除此之外,我收到此错误 -

如果我将 cmets 保留在 routes.rb 文件中,

# match ':controller(/:action(/:id))(.:format)'

然后这条消息标记 -

当我取消注释此行时,它会显示此错误-

对 Rails 的了解很少,因为我来自 PHP 背景,但在理论之前仍然尝试一些实际测试,所以让我知道我到底做错了什么。

我的 routes.rb 文件 -

Prjmgt::Application.routes.draw do
  devise_for :users

  # The priority is based upon order of creation:
  # first created -> highest priority.

  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', :on => :collection
  #     end
  #   end

  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => 'welcome#index'
    root :to => 'home#index'

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
   match ':controller(/:action(/:id))(.:format)'
end

只需运行rake routes 命令并找到它 -

【问题讨论】:

  • 请显示您的路线 rb
  • @Lichtamberg 刚刚粘贴,如果您需要其他任何调查,请告诉我..目前处于学习模式..需要你们的支持,而不是 Rails tuts :)
  • @Lichtamberg 请在下面找到我的 cmets

标签: ruby-on-rails devise ruby-on-rails-3.2 rails-routing


【解决方案1】:

您访问了错误的 url.. 您应该尝试使用

http://application/users/login

你没有像这样的正确的根 url

root :to => redirect("/users/login")

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-10
  • 2014-02-26
  • 1970-01-01
  • 2017-08-31
相关资源
最近更新 更多