简体   繁体   English

设计Rails 3.2.6中的路由错误

[英]Devise Routing Error in rails 3.2.6

I've looked through all the Devise routing error discussions here and couldn't find a solution that fixes my problem. 我已经浏览了所有Devise路由错误讨论,但是找不到解决我的问题的解决方案。 My environments are the following: - Ruby 1.9.3 - Rails 3.2.6 - Devise 2.2.0 我的环境如下:-Ruby 1.9.3-Rails 3.2.6-Devise 2.2.0

I followed all the steps here: https://github.com/plataformatec/devise 我在这里遵循了所有步骤: https//github.com/plataformatec/devise

The files are: 这些文件是:

routes.rb: routes.rb中:

Dealzhunt::Application.routes.draw do

  devise_for :members 

  get "browse/all"

  get "home/index"

  root :to => 'browse#all'

# some other code

member.rb: member.rb:

class Member < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
  # attr_accessible :title, :body
end

rake routes: 耙路:

          new_member_session GET    /members/sign_in(.:format)       devise/sessions#new
              member_session POST   /members/sign_in(.:format)       devise/sessions#create
      destroy_member_session DELETE /members/sign_out(.:format)      devise/sessions#destroy
             member_password POST   /members/password(.:format)      devise/passwords#create
         new_member_password GET    /members/password/new(.:format)  devise/passwords#new
        edit_member_password GET    /members/password/edit(.:format) devise/passwords#edit
                             PUT    /members/password(.:format)      devise/passwords#update
  cancel_member_registration GET    /members/cancel(.:format)        devise/registrations#cancel
         member_registration POST   /members(.:format)               devise/registrations#create
     new_member_registration GET    /members/sign_up(.:format)       devise/registrations#new
    edit_member_registration GET    /members/edit(.:format)          devise/registrations#edit
                             PUT    /members(.:format)               devise/registrations#update
                             DELETE /members(.:format)               devise/registrations#destroy
                  browse_all GET    /browse/all(.:format)            browse#all
                        root        /                                browse#all

For the following URLs: 对于以下URL:

http://localhost:3000/members/sign_in
http://localhost:3000/members/sign_up

i'm getting the following error: 我收到以下错误:

No route matches {:controller=>"devise/browse", :action=>"all", :category=>0}

One strange symptom I observed is that if I modify root :to => 'home#index', the message is the same. 我观察到的一种奇怪症状是,如果我将root:to修改为=>'home#index',则消息是相同的。 I thought it would at least change to devise/home but it remained at /browse 我以为它至少会改变设计/房屋,但仍留在/浏览

Strangest thing is I start a new clean rails project, devise actually works. 最奇怪的是,我启动了一个新的Clean Rails项目,该设计实际上是有效的。 I'm wondering if it's because some error happened when I ran rails generate devise:install 我想知道是否是因为当我运行rails generate devise:install时发生了一些错误

Really stuck with this issue. 确实陷入了这个问题。 Can someone help me please? 有人能帮助我吗?

Dear lord I found out the cause of the problem. 亲爱的上帝,我找出了问题的原因。 Devise is having trouble with the link_to syntax. Devise在使用link_to语法时遇到麻烦。 A temporary solution is to modify all the link_to to 临时解决方案是将所有link_to修改为

<%= link_to "Home", :controller => "/browse", :action => "all" %>

with the / before the controller name. 在控制器名称前加上/。 Here's more details on the issue: github.com/plataformatec/devise/issues/471 以下是有关该问题的更多详细信息:github.com/plataformatec/devise/issues/471

Where are you getting this error? 您从哪里得到此错误? Ie, which page are you loading? 即,您正在加载哪个页面?

It seems like you are having a link or something on it that routes to the controller "devise/browse" - instead, it should only route to the controller "browse". 似乎您正在链接或路由到控制器“设计/浏览”的某物-相反,它应该仅路由到控制器“浏览”。 In the output generated by rake routes 在rake路由生成的输出中

browse_all GET    /browse/all(.:format)            browse#all

you will see that you apparently have a browse controller with an all method. 您会发现您显然拥有一个带有all方法的browse器控制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM