Previously had my devise models working but now all the routes are failing. I have two models users and admins. Each have additional attributes from the normal, :firstname, :lastname, etc and each have separate controllers that are the same and extensions of the Devise RegistrationsController. This all started when I began adding bootstrap. For example when I try to sign_out I get this error:
No route matches [GET] "/users/sign_out" Rails.root: /Users/elizabeth/Desktop/ecoCalculator
I'm not sure what is causing it to think that sign-out is a [GET]
When I try to enter /admins/sign_up I get:
ActionController::UrlGenerationError in Devise::Sessions#new Showing /Users/elizabethzweizig/Desktop/ecoCalculator/app/views/layouts/application.html.erb where line #61 raised: No route matches {:action=>"index", :controller=>"devise/posts"}
This refers to a part of the Bootstrap navbar but posts is not linked to devise. Posts do not belong to users nor admins.
Below is an example of my extended RegistrationsController
class AdminRegistrationsController < Devise::RegistrationsController
private
def sign_up_params
params.require(:user).permit(:first_name, :last_name, :username, :hometown, :email, :password, :password_confirmation)
end
def account_update_params
params.require(:user).permit(:first_name, :last_name, :username, :hometown, :email, :password, :password_confirmation, :current_password)
end
end
And here is my routes.rb file
Rails.application.routes.draw do
devise_for :users, :controllers => { registrations: 'registrations' } do
resources :waterusage
end
devise_for :admins, :controllers => { admin_registrations: 'admin registrations' }
get 'welcome/index'
get 'waterusage/result' => "waterusages#results"
resources :posts do
resources :comms
end
resources :waterusages
resources :goals
get "myprofile" => "yours#profile", :as => :myprofile
root 'welcome#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
In the route
devise_for :admins, :controllers => { admin_registrations: 'admin registrations' }
it will admin/registrations
not admin registrations
, change this and see what's happening
look the format
devise_for :users, :controllers => { registrations: 'users/registrations' } do
resources :waterusage
end
devise_for :admins, :controllers => { registrations: 'admins/registrations' }
and check the app/assets/javascripts/application.js
first two lines should
//= require jquery
//= require jquery_ujs
if exist require rails-ujs
remove this
I fixed the problem, I ended up doing a hard reset to my last commit so that I could track my changes more carefully. It actually was related to my Bootstrap. When I edited the application.html.erb file I had moved.
<%= csrf_meta_tags %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
Once I added this back into the project. The devise worked again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.