路由错误:没有路由匹配[GET]" / users / sign_up"

时间:2016-02-08 12:46:24

标签: ruby-on-rails ruby devise

我是stackoverflow的新手,最近我学习了Ruby on Rails。我无法解决本地主机的问题:没有路由匹配[GET]" / users / sign_up" (设计宝石)。

这是我的代码:

routes.rb中:

Rails.application.routes.draw do

  resources :posts do
    resources :comments
  end

  root 'posts#index'

  get '/about' => 'pages#about'

end

config / development.rb 中我添加了:

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

佣金路线显示:

post_comments_path  GET /posts/:post_id/comments(.:format)  comments#index
                    POST    /posts/:post_id/comments(.:format)  comments#create
new_post_comment_path   GET /posts/:post_id/comments/new(.:format)  comments#new
edit_post_comment_path  GET /posts/:post_id/comments/:id/edit(.:format) comments#edit
post_comment_path   GET /posts/:post_id/comments/:id(.:format)  comments#show
                    PATCH   /posts/:post_id/comments/:id(.:format)  comments#update
                    PUT /posts/:post_id/comments/:id(.:format)  comments#update
                    DELETE  /posts/:post_id/comments/:id(.:format)  comments#destroy
posts_path  GET /posts(.:format)    posts#index
                    POST    /posts(.:format)    posts#create
new_post_path   GET /posts/new(.:format)    posts#new
edit_post_path  GET /posts/:id/edit(.:format)   posts#edit
post_path   GET /posts/:id(.:format)    posts#show
                    PATCH   /posts/:id(.:format)    posts#update
                    PUT /posts/:id(.:format)    posts#update
                    DELETE  /posts/:id(.:format)    posts#destroy
root_path   GET /   posts#index
about_path  GET /about(.:format)    pages#about

我重新启动了服务器,但没有任何帮助。我还没有在类似主题中找到一个好的暗示。

由于

2 个答案:

答案 0 :(得分:0)

好的,我找到了解决方案。 在gemfile中应该是:

  

宝石'设计':git => 'https://github.com/plataformatec/devise.git'

(v.4.0.0)而不是

  

宝石'设计''〜> 3.3.0'

Devise 3.3.0与Rails 4.2不兼容。

由于

答案 1 :(得分:0)

如果您使用以下默认Devise Routes

`/`             `POST`      `Email registration`
`/`             `DELETE`    `Account deletion`. 
`/`             `PUT`       `Account updates`
`/sign_in`      `POST`      `Email authentication`.
`/sign_out`     `DELETE`    

然后devise_for :users您不需要user/auth,而只需使用//auth(基于:选项是{{1}}在设计中定义的路线 所有路线都在文件中明确定义