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'
Related
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.
I've got a Rails 4 app that I'm trying to reconfigure to use subdomains for jobportals. Right now the root path for each portal is /jobportals/:id. What I want is for a user to be able to go to client.example.com and hit that root path. Then for example, if the user edits their profile, the url would be client.example.com/user/edit rather than www.example.com/jobportals/:id/user/edit.
I followed this ASCIIcasts tutorial on setting up subdomain routing, but it's not working for me. When I go to http://client.lvh.me:3000/, I am hitting the root_path of my Rails app, rather than the root_path for the portal.
I think the problem is that Constraints(Subdomain) isn't working with resources :jobportals. How can I reconfigure my routes to accomplish what I'm after?
MyApp::Application.routes.draw do
devise_for :users, :controllers => {:registrations => "registrations"}
root 'general#home'
get '/about' => 'general#about'
get '/team' => 'general#team'
get '/careers' => 'general#careers'
get '/terms' => 'general#terms'
get '/privacy_policy' => 'general#privacy_policy'
constraints(Subdomain) do
resources :jobportals, controller: 'portals/general' do
member do
root 'portals/general#home'
devise_scope :user do
get '/user/sign_in' => 'portals/sessions#new'
post '/user/sign_in' => 'portals/sessions#create'
delete '/user/sign_out' => 'portals/sessions#destroy'
post '/user/password' => 'portals/passwords#create'
get '/user/password/new' => 'portals/passwords#new'
get '/user/password/edit' => 'portals/passwords#edit'
patch '/user/password' => 'portals/passwords#update'
put '/user/password' => 'portals/passwords#update'
post '/user' => 'portals/registrations#create'
get '/user/sign_up' => 'portals/registrations#new'
get '/user/edit' => 'portals/registrations#edit'
patch '/user' => 'portals/registrations#update'
put '/user' => 'portals/registrations#update'
delete '/user' => 'portals/registrations#destroy'
end
get '/jobs' => 'portals/general#jobs'
get '/companies' => 'portals/general#companies'
get '/alljobs' => 'portals/general#alljobs'
resources :applications, controller: 'portals/applications'
get ':id' => 'portals/companies#profile'
get ':id/jobs' => 'portals/companies#jobs'
get ':id/jobfunctions' => 'portals/companies#jobfunctions'
end
end
end
end
Working Code Below
MyApp::Application.routes.draw do
devise_for :users, :controllers => {:registrations => "registrations"}
root 'general#home'
get '/about' => 'general#about'
get '/team' => 'general#team'
get '/careers' => 'general#careers'
get '/terms' => 'general#terms'
get '/privacy_policy' => 'general#privacy_policy'
constraints(Subdomain) do
get '/' => 'portals/general#home'
devise_scope :user do
get '/user/sign_in' => 'portals/sessions#new'
post '/user/sign_in' => 'portals/sessions#create'
delete '/user/sign_out' => 'portals/sessions#destroy'
post '/user/password' => 'portals/passwords#create'
get '/user/password/new' => 'portals/passwords#new'
get '/user/password/edit' => 'portals/passwords#edit'
patch '/user/password' => 'portals/passwords#update'
put '/user/password' => 'portals/passwords#update'
post '/user' => 'portals/registrations#create'
get '/user/sign_up' => 'portals/registrations#new'
get '/user/edit' => 'portals/registrations#edit'
patch '/user' => 'portals/registrations#update'
put '/user' => 'portals/registrations#update'
delete '/user' => 'portals/registrations#destroy'
end
get '/jobs' => 'portals/general#jobs'
get '/companies' => 'portals/general#companies'
get '/alljobs' => 'portals/general#alljobs'
resources :applications, controller: 'portals/applications'
get ':id' => 'portals/companies#profile'
get ':id/jobs' => 'portals/companies#jobs'
get ':id/jobfunctions' => 'portals/companies#jobfunctions'
end
end
It is looking like constraints are not define properly, it is something like get 'jobportals', constraints: {subdomain: 'subdomain_name'}
Checkout the rails guide
I had User model for a while that worked with devise, now I have to add a new model to the app, called Profile, and as it has almost the same attributes as User I decided to inherit Profile from User.
user.rb
class User < ActiveRecord::Base
...
end
profile
class Profile < User
...
end
updated routes to work with devise:
devise_for :users, :path => '', :path_names => {:sign_up => "becometutor"},
:controllers => { :registrations => "users/registrations" }
devise_for :profiles, :path => '', :path_names => { :sign_up => "brand_profile"},
:controllers => { :registrations => "profiles/registrations" }
rake routes
user_registration POST / users/registrations#create
new_user_registration GET /becometutor(.:format) users/registrations#new
profile_registration POST / profiles/registrations#create
new_profile_registration GET /brand_profile(.:format) profiles/registrations#new
Problem
When I open new_profile_registration logs shows:
Processing by Profiles::RegistrationsController#new as HTML
when I click submit on form that should create a profile, logs shows:
Processing by Users::RegistrationsController#create as JS
Parameters: {"utf8"=>"✓", "profile"=>{"name"=>"", "phone"=>"", "owner_name"=>"", "owner_phone_number"=>""
Question
why create action points to Users::RegistrationController, instead of Profiles::RegistrationController ?
Thank you.
Fix - set path to be different for each resource
devise_for :users, :path => 'tutors', :path_names => {:sign_up => "becometutor"},
:controllers => { :registrations => "users/registrations" }
devise_for :profiles, :path => 'profiles', :path_names => { :sign_up => "brand_profile"},
:controllers => { :registrations => "profiles/registrations" }
You have 2 routes with the same url, user_registration POST / and profile_registration POST /, so Rails looks for the first, and it's point to users/registrations#create
I am not sure but i guess it is due routes . If you put profile route above user route , it might work.
You might be passing #user simply to the form_for and it is picking user create path as it comes first.
I am currently trying to get my Ruby on Rails application running in a production environment. It is working fine but when I added a route under a nested namespace it is giving me error saying
ActionController::RoutingError (uninitialized constant Agent::Clients::AccountController)
This routes are working fine on my local machine, The route looks like this
namespace :agent do
root :to => redirect('url')
match 'dashboard', :to => 'dashboard#index'
match 'account', :to => 'account#edit'
match 'account/update', :to => 'account#update'
namespace :clients do
root :to => redirect('url')
**# This part I added and is giving routing error**
match 'accounts/invite', :to => 'clients/account#invite'
match 'accounts/sendinvite', :to => 'clients/account#send_invitation'
My rake routes giving the routes properly.
Any suggestions how to fix this issue ?
So you either want to do
match 'accounts/invite', :to => 'clients/accounts#invite'
match 'accounts/sendinvite', :to => 'clients/accounts#send_invitation'
Or
match 'accounts/invite', :to => 'agent/account#invite'
match 'accounts/sendinvite', :to => 'agent/account#send_invitation'
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 %>