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 %>
Related
I want to change the default path of some user (in this case with id = 1) information from:
domain.com/user.1
to
domain.com/user/1
I already use devise_for on my route.rb, is there some special command to do what I need with this?
this is my route.rb
devise_for :users,
:path => '',
:path_names => {
:sign_in => 'login',
:sign_out => 'logout',
:sign_up => 'register'
},
:controllers => { registrations: 'registrations' }
First, domain.com/user.1 doesn't look like a real route to me. Are you sure you're not calling users_path(id) when you intend to call user_path(id)?
Also, a user/:id route doesn't look like it has anything to do with Devise, which is concerned with authentication/authorization. It looks more like a show resource method that would go in UsersController#show.
In any case, the following route should give you the /user/:id route which maps to UsersController#show
resources :user
which would create the following route helper method:
user_path(id)
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 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 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'
For some strange reason cardsets_path('my') generates "/cardsets.my" instead of "/cardsets/my". Please explain why?
config/routes.rb:
match '/cardsets/:type', :to => 'cardsets#index', :requirements => { :type => /my|public/ }, :as => 'cardsets'
resources :users do
resources :cardsets do
end
end
rake routes:
cardsets /cardsets/:type(.:format) {:controller=>"cardsets", :action=>"index"}
Shouldn't it be
cardsets_path(:type => 'my')
However, type is a reserved word in rails.