In rails 5, I am using NewRelic to monitor the application. In newrelic, instantly I am getting Middleware/Rack/ActionDispatch::Routing::RouteSet#call as most time consuming. I don't know why this issue is happening.
In routes.rb,
devise_for :admins
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
scope :api do
scope :v1 do
devise_for :users, controllers: {
registrations: 'users/registrations',
confirmations: 'users/confirmations',
sessions: 'users/sessions',
passwords: 'users/passwords'
}
get 'confirm_user_email', to: 'user_emails#confirm_email', as: :confirm_user_email
get 'forgot_password', to: 'landing_page#forgot_password'
post 'send_invitation', to: 'users#send_invitation', as: :send_invitation
end
end
unless Rails.env.production?
mount LetterOpenerWeb::Engine, at: '/letter_opener'
end
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'
get "*path" => "home#index"
mount ActionCable.server => '/cable'
Please help me to solve this issue.
Please move the newrelic_rpm to the bottom of the Gemfile. This is required as when server starts, ruby agent should load up first and then the new relic agent so that the transaction calls can be routed through new relic agent so that new relic captures the transactions.
Related
I have a few links that are breaking. One, my logout, which I am using the delete method with, returns this error:
[Devise] Could not find devise mapping for path "/users/sign_out". This may happen for two reasons: 1) You forgot to wrap your route inside the scope block. For example: devise_scope :user do get "/some/route" => "some_devise_controller" end 2) You are testing a Devise controller bypassing the router. If so, you can explicitly tell Devise which mapping to use: #request.env["devise.mapping"] = Devise.mappings[:user]
I have this in my routes: get '/users/sign_out', to: 'devise/sessions#destroy'
And my devise routes look like this:
devise_for :users, controllers: { sessions: 'sessions',
registrations: 'registrations',
invitations: 'invitations' }
Why is this breaking?
I have this in my routes: get '/users/sign_out', to: 'devise/sessions#destroy'
if you want to allow the user to sign out via GET method all you have to do is go to app/config/initializers/devise.rb and uncomment the line config.sign_out_via = :get
OR Try this
devise_scope :user do
get '/users/sign_out', to: 'devise/sessions#destroy'
end
I'm receiving the following error when trying to go to http://app.mysite.dev/login -
Could not find devise mapping for path "/login".
This may happen for two reasons:
1) You forgot to wrap your route inside the scope block. For example:
devise_scope :user do
get "/some/route" => "some_devise_controller"
end
2) You are testing a Devise controller bypassing the router.
If so, you can explicitly tell Devise which mapping to use:
#request.env["devise.mapping"] = Devise.mappings[:user]
Now, here is the relevant bits of my routes.rb file:
namespace 'app', path: '', constraints: { subdomain: 'app' } do
devise_for :users, :skip => [:registrations, :confirmations]
devise_for :agents, :skip => :sessions
devise_scope :users do
get "login" => "users/sessions#new"
end
...
end
And the route generated by the get "login" line is as follows (from rake routes)
app_login GET /login(.:format) app/users/sessions#new {:subdomain=>"app"}
I don't know if it matters, but I'm using STI for Users > Agents relationship.
So, I already am defining the scope for devise, and I'm not testing, so any ideas what's going on?
Try to replace your devise_scope with the following instead. Within your namespace 'app' block.
devise_scope :app_user do
get "login" => "users/sessions#new"
end
It appears to be devise was changing the scope it was looking for within a namespace.
For your reference:
https://github.com/plataformatec/devise/issues/2496
And yeah, it should be devise_scope :app_user instead of devise_scope :app_users
It's just a simple typo - devise_scope :users should be devise_scope :user, as stated in the error message.
It seems you didn't define a custom SessionsControllerfor your :users, and Devise cannot use it's default one since you namespaced your devise_scope :users.
I'd define your own custom class App::SessionsController and then add it rewrite your routes like this:
namespace 'app', path: '', constraints: { subdomain: 'app' } do
devise_for :users, controllers: { sessions: 'sessions' }, skip: [:registrations, :confirmations]
devise_scope :users do
get "login" => "sessions#new"
end
end
I installed rails admin (https://github.com/sferik/rails_admin). But now when i go to localhost:3000 i get the following error
No route matches {:controller=>"devise/access", :action=>"logout"}.
I have added the following to the top of my routes.rb but am still getting the above error when i go to localhost:3000 or localhost:3000/admin
devise_for :railsadmin_users
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
How can i fix this ?
Thank You
These are my admin routes using Devise, hope it helps.
devise_for :admins, :controllers => { :registrations => "devise/registrations", :passwords => "devise/passwords" }
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
I have this route file
Qitch::Application.routes.draw do
devise_for :users, :controllers => {
:omniauth_callbacks => "users/omniauth_callbacks",
:registrations => "users/registrations",
:sessions => "users/sessions",
:passwords => "users/passwords"
}
devise_for :users
as :user do
get '/sign_up', :to => "users/registrations#new"
get "sign_out", :to => "users/sessions#destroy"
end
root :to => 'welcome#index'
end
when i click on this link in application layout
Sign-up Now, It's fast and free
i have this error
Routing Error
No route matches {:controller=>"users/welcome"}
Try running rake routes for more information on available routes.
I don't understand why this occur
Any help
Thanks
1.) as the Routing Error promts, try to run rake routes which will show you all defined routes, from the output you can see if you defined something not as wanted
2.) as stated in devise custom routes try something like:
get "/sign_up" => "devise/registrations#new"
3.) use the paths in your view: generating paths and urls from code
<%= link_to "Login", signup_user_path %>
I have finally gotten the on_the_spot gem working in my rails app, which uses devise for authentication.
But, when a user is logged in, making an edit on the user 'show' page results in them being immediately logged out after the change is made (and saved). My guess is that this is to do with routes.rb?
get "users/index"
get "users/show"
devise_for :users, :controllers => { :registrations => :registrations }
devise_for :users
resources :users
root :to => "home#index"
match '/:id' => 'users#show'
resources :users do
collection do
post :update_attribute_on_the_spot
end
end
Are there any obvious errors in this that would cause my problem? Or should I be looking elsewhere? I'm using Rails 3.0.10 and the latest versions of Devise/on_the_spot.
Many thanks!