I am following this guide https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
to configure devise with omniauth facebook sign up, now I am at the step where I need to add the omniauth_callbacks route to the devise routes, i have already customized a devise controller like this :
devise_for :users, controllers:{
registrations: "users/registrations"
}
So I added the omniauth route like this
devise_for :users, controllers:{
registrations: "users/registrations"
:omniauth_callbacks => "users/omniauth_callbacks"
}
But now the server is not starting because of a syntax error, I am pretty sure I need a block in the routes.
Please advise.
Thanks
You just have a missing comma
devise_for :users, controllers: {
registrations: "users/registrations",
omniauth_callbacks: "users/omniauth_callbacks"
}
Related
Here's my issue, I want to correctly nest my devise routes from :
user_je_session POST /users/jes/:je_id/sign_in(.:format)
to :
user_je_session POST /jes/:je_id/users/sign_in(.:format)
The objective is that my users can have multiple accounts, depending on the "je" they want to access.
there's my actual routes :
root to: 'pages#home'
devise_for :admins, controllers: { sessions: 'admin/sessions', registrations: 'admin/registrations' }
resources :jes, param: :nom do
devise_for :users, controllers: { sessions: 'users/sessions', registrations: 'users/registrations' }
end
Thanks for your help
I think it's easier to use devise_scope. You can customize the devise routes as you wish. Something like this might be work:
devise_for :admins, controllers: {
sessions: 'admin/sessions',
registrations: 'admin/registrations'
}
as :admin do
# Please change to: value to your actual controller or action
post '/jes/:je_id/users/sign_in', to: 'admin/sessions#create'
end
Please read more on the documentation page.
https://github.com/heartcombo/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes
I'm having issues with routing with Devise and my Users model. I was trying to get sign_out to work and found an answer that suggested this.
// routes.rb
devise_for :users do
get '/users/sign_out' => 'devise/sessions#destroy'
get '/users/sign_in' => 'devise/sessions#create'
end
And while this works for signing out, if I use just that I cannot view a User.
No route matches [GET] "/users/1"
However, if I add back resources :users, I run into the first issue where sign_out or sign_in try to view a User.
Couldn't find User with 'id'=sign_out
How do I add /users/index to the devise_for loop?
Thanks for your help.
Try adding resources :users after your devise_for block.
You can also use the following:
devise_for :users, path: '', path_names: { sign_in: 'login', sign_out: 'logout'}
I'm developing an app that at this moment has only one model with login, called reader.
But in the future, there will be another model called company that will require login as well.
So I'm thinking what's the best way to develop it.
I thought that having a model called login with:
email
password
models reader
company inherit from it
but I have no idea if it's the best way to do it.
I'm not using any gem like Devise.
I'm developing my own login system.
So, what do you recommend?
Whats the best way?
Thanks so much!
When the different users that use the application have completely different experience what I use is devise
in your Gemfile
gem "devise"
then you install
rails generate devise:install
then you create your models
rails generate devise user
rails generate devise manager
Here is the key in your routs you can do something like this
devise_for :users, :controllers => {
registrations: 'users/registrations',
sessions: 'users/sessions',
passwords: 'users/passwords',
confirmations: 'users/confirmations'
}
authenticate :user do
namespace :users do
...
root :to => 'dashboards#index'
end
end
devise_for :managers, :controllers => {
registrations: 'managers/registrations',
sessions: 'managers/sessions"'
passwords: 'managers/passwords',
confirmations: 'managers/confirmations'
}
authenticate :manager do
namespace :managers do
...
root :to => 'dashboards#index'
end
end
[i have customize the devise gem controller in my application]
[error comes : uninitialized constant SessionsController]
i also copies the view in to the separate section but still it comes
in your routes.rb must be devise_for like this
devise_for :users, controllers: { registrations: 'users/registrations', sessions: 'users/sessions'}
I'm trying to modify an existing devise route to hold parameters
Here is the working route:
devise_for :contributors, controllers: {registrations: 'contributors/registrations', confirmations: 'contributors/confirmations'}
the working path:
<p>Create Account</p>
I need to be able to pass a parameter with it. Is there a simple way to do this?
I was thinking of doing something like this:
devise_for :contributors, controllers: {registrations: 'contributors/registrations(/:contributor_type)', confirmations: 'contributors/confirmations'}
<p>Create Account</p>
but no luck, it only returns this error: wrong constant name Registrations(
Nevermind, I didn't need to place a parameter inside the devise_for route declaration.
devise_for :contributors, controllers: {registrations: 'contributors/registrations', confirmations: 'contributors/confirmations'}
this works just fine with
<p>Create Account</p>