devise_invitable routing error

﹥>﹥吖頭↗ 提交于 2019-12-12 04:44:59

问题


THE ERROR:

Started GET "/users/invitation/new" for 127.0.0.1 at 2013-01-09 01:00:31 +0100
  Processing by Devise::InvitationsController#new as HTML
  User Load (451.8ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
Rendered users/invitations/new.html.erb within layouts/application (69.2ms)
Rendered layouts/_google_analytics.html.erb (0.4ms)
Rendered layouts/_navbar.html.erb (73.6ms)
Completed 500 Internal Server Error in 10785ms

ActionView::Template::Error (No route matches {:controller=>"devise/dashboards", :action=>"show"}):
    23:         </ul>
    24:         <ul class="nav pull-right" id="main-menu-right">
    25:             <% if user_signed_in? %>
    26:                 <li><%= link_to raw("My Agenda"), {:controller => :dashboards, :action => :show}, :tabindex => "-1" %></li>
    27:                 <li><%= link_to raw("My Services"), {:controller => :creative_services, :action => :index_my_services}, :tabindex => "-1" %></li>
    28:                 <li id="fat-menu" class="dropdown">
    29:                   <a href="#" id="dropUser" role="button" class="dropdown-toggle" data-toggle="dropdown">
  app/views/layouts/_navbar.html.erb:26:in `_app_views_layouts__navbar_html_erb__952134567516339951_70121556350080'
  app/views/layouts/application.html.erb:18:in `_app_views_layouts_application_html_erb___2663940439779075013_70121556359600'

On my Rails 3.1 project, I already use Devise.

I added devise_invitable gem in my Gemfile:

gem "devise", "~> 2.0.0"
gem 'devise_invitable', '~> 1.0.0'

Run these commands

rails generate devise_invitable:install
rails generate devise_invitable User
rake db:migrate
rails generate devise_invitable:views users

Set options in Devise.rb (Unlimited invitations

config.invitation_limit = 

and start my server.

When I try to access /users/invitation/new

I am getting a routing error

Routing Error

No route matches {:controller=>"devise/dashboards", :action=>"show"}

In my User model:

devise :invitable, :database_authenticatable, :registerable, :confirmable,
     :recoverable, :rememberable, :trackable, :validatable, :invitable

My routes file:

devise_for :users, :controllers => { :registrations => 'registrations' }

How can I fix this routing issue?


回答1:


workaround found here Routing error with devise {:controller=>"devise/static", :action=>"about"}

Changed my links:

26:  <li><%= link_to raw("My Agenda"), {:controller => :dashboards, :action => :show}, :tabindex => "-1" %></li>
27:  <li><%= link_to raw("My Services"), {:controller => :creative_services, :action => :index_my_services}, :tabindex => "-1" %></li>

to:

<li><%= link_to raw("My Agenda"), "/dashboards/show", :tabindex => "-1" %></li>
<li><%= link_to raw("My Services"), "/creative_services/index_my_services", :tabindex => "-1" %></li>

"and then all worked fine"



来源:https://stackoverflow.com/questions/14226107/devise-invitable-routing-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!