SSL integration with Devise How-To, Not Authenticating - ruby-on-rails-3

I am using SSL Requirement to achieve the proper rediects with Devise. I am using custom devise controllers so I am able to drop in the ssl_required in them.
Gemfile
gem 'bartt-ssl_requirement', '1.2.7', :require => 'ssl_requirement'
application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
include ::SslRequirement
I also customized the hostname for SSLRequirement
production.rb
config.after_initialize do
SslRequirement.ssl_host = 'secure.website.com'
end
Setting up Custom Devise Controllers is as simple as making a new controller file and having the appropriate naming: (e.g. Session Controller). Be sure to generate the views and move them into the appropriate folder so your custom controller can use them.
session_controller.rb
class SessionsController < Devise::SessionsController
ssl_exceptions
def new
super
end
...
All this is working for met yet once I enable ssl_required (or ssl_exceptions), Devise is no longer able to authenticate. It redirects me to index or keeps me on the login page.
I made sure to go into session_store.rb and update my cookie_store to include
session_store.rb
App::Application.config.session_store :cookie_store, :key => '_app_session', :httponly => true, :secure => true, :domain => '.website.com'
for me, adding :domain => :all was not solving the problem either
Went into my devise.rb file and included:
devise.rb
config.cookie_options = { :secure => true }
still no success... even wrote all custom routes skipping over Devise defaults so they would include the https protocol and the secure subdomain host, and skip default devise routes to get rid of duplicate paths... I'm running out of options at this point:
routes.rb
constraints :protocol => "https", :host => "secure.website.com" do
devise_for :users, :controllers => { :sessions => 'sessions', :registrations => 'registrations', :passwords => 'passwords', :confirmations => 'confirmations', :unlocks => 'unlocks' }, :skip => [:sessions, :passwords, :registrations]
devise_scope :user do
#sessions
get "/users/sign_in" => "sessions#new", :as => nil
get "/users/sign_in" => "sessions#new", :as => :new_user_session
get "/users/sign_in" => "sessions#new", :as => :users_sign_in
get "/users/sign_out" => "sessions#destroy", :as => :destroy_user_session
get "/users/sign_out" => "sessions#destroy", :as => :users_sign_out
post "/users/sign_in" => "sessions#create", :as => :user_session
post "/users/sign_in" => "sessions#new", :as => nil
#registrations
get "/users/sign_up" => "registrations#new", :as => :users_sign_up
get "/users/sign_up" => "registrations#new", :as => :new_user_registration
get "/users/edit" => "registrations#edit", :as => :users_edit
get "/users/edit" => "registrations#edit", :as => :edit_user_registrations
get "/users/cancel" => "registrations#cancel", :as => :cancel_user_registration
post "/users/" => "registrations#create", :as => :user_registration
put "/users" => "registrations#update"
delete "/users" => "registrations#destroy"
#passwords
get "/users/password/new" => "passwords#new", :as => :users_password_new
get "/users/password/new" => "passwords#new", :as => :new_user_password
get "/users/password/edit" => "passwords#edit", :as => :edit_user_password
post "/users/password" => "passwords#create"
put "/users/password" => "passwords#update"
end
devise_for :admins, :controllers => { :sessions => 'sessions', :registrations => 'registrations', :passwords => 'passwords', :confirmations => 'confirmations', :unlocks => 'unlocks' }, :skip => [:sessions, :unlocks]
as :admin do
#sessions
get "/admins/sign_in" => "sessions#new"
get "/admins/sign_in" => "sessions#new", :as => :admins_sign_in
get "/admins/sign_in" => "sessions#new", :as => :new_admin_session
get "/admins/sign_out" => "sessions#destroy", :as => :destroy_admin_session
get "/admins/sign_out" => "sessions#destroy", :as => :admins_sign_out
post "/admins/sign_in" => "sessions#new"
post "/admins/sign_in" => "sessions#new", :as => :admin_session
#unlocks
get "/admins/unlock" => "unlocks#show"
get "/admins/unlock/new" => "unlocks#new", :as => :admins_unlock_new
get "/admins/unlock/new" => "unlocks#new", :as => :new_admin_unlock
post "/admins/unlock" => "unlocks#create", :as => :admin_unlock
end
end
rake routes
GET /users/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"new"}
new_user_session GET /users/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"new"}
users_sign_in GET /users/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"new"}
destroy_user_session GET /users/sign_out(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"destroy"}
users_sign_out GET /users/sign_out(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"destroy"}
user_session POST /users/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"create"}
POST /users/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"new"}
users_sign_up GET /users/sign_up(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"registrations", :action=>"new"}
new_user_registration GET /users/sign_up(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"registrations", :action=>"new"}
users_edit GET /users/edit(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"registrations", :action=>"edit"}
edit_user_registrations GET /users/edit(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"registrations", :action=>"edit"}
cancel_user_registration GET /users/cancel(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"registrations", :action=>"cancel"}
user_registration POST /users(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"registrations", :action=>"create"}
users PUT /users(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"registrations", :action=>"update"}
DELETE /users(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"registrations", :action=>"destroy"}
users_password_new GET /users/password/new(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"passwords", :action=>"new"}
new_user_password GET /users/password/new(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"passwords", :action=>"new"}
edit_user_password GET /users/password/edit(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"passwords", :action=>"edit"}
users_password POST /users/password(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"passwords", :action=>"create"}
PUT /users/password(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"passwords", :action=>"update"}
admins_sign_in GET /admins/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"new"}
admins_sign_in GET /admins/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"new"}
new_admin_session GET /admins/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"new"}
destroy_admin_session GET /admins/sign_out(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"destroy"}
admins_sign_out GET /admins/sign_out(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"destroy"}
POST /admins/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"new"}
admin_session POST /admins/sign_in(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"sessions", :action=>"new"}
admins_unlock GET /admins/unlock(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"unlocks", :action=>"show"}
admins_unlock_new GET /admins/unlock/new(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"unlocks", :action=>"new"}
new_admin_unlock GET /admins/unlock/new(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"unlocks", :action=>"new"}
admin_unlock POST /admins/unlock(.:format) {:protocol=>"https", :host=>"secure.website.com", :controller=>"unlocks", :action=>"create"}
I am almost positive it has to do with my cookies, anyone have 2 cents?
I can post more app code or console code if need be. I hope this has been a help to anyone setting up customized Devise and anyone incorporating SSL into their rails3 app using Devise and SSLRequirement.
Hopefully we can get a complete write-up for a solid example for everyone. Thanks and let me know if you have any questions about how I set up custom devise controllers/views/etc...

Related

cleaning up rails 3 routes

I am using devise with few changes to the controllers and have the following routes defined.
devise_for :users, skip: [:registrations, :sessions]
devise_scope :user do
resource :registration,
only: [:new, :create, :edit, :update],
path: 'users',
path_names: { new: 'sign-up' },
controller: 'registrations',
as: :user_registration do
get :cancel
end
get 'sign-in' => 'devise/sessions#new', :as => :new_user_session
post 'sign-in' => 'devise/sessions#create', :as => :user_session
delete 'sign-out' => 'devise/sessions#destroy', :as => :destroy_user_session
get "sign-up" => "registrations#new", :as => :new_user_registration
end
resulting in the following duplicate routes:
new_user_registration GET /users/sign-up(.:format) registrations#new
new_user_registration GET /sign-up(.:format) registrations#new
How do i clean my route file that the duplication does not occur.
not sure, postet as answer for format:
I think that the redundancy cames from here:
devise_scope :user do
resource :registration,
only: [:new, :create, :edit, :update],
path: 'users',
path_names: new: 'sign-up' ,
this makes the
new_user_registration GET /users/sign-up(.:format) registrations#new
and
get "sign-up" => "registrations#new", :as => :new_user_registration
adds
new_user_registration GET /sign-up(.:format) registrations#new
so leave one of them

link_to update a Devise user, method => put

I'm trying to update a single databasefield of my current_user (devise).
I want to do this just with the link_to helper:
<%= link_to "Grid", edit_user_registration_path(current_user, :project_view => "grid"), :method => :put %>
But I can't get it to work since the result it allways an error:
Routing Error
No route matches [PUT] "/users/edit.1"
My Routes for Devise:
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
What's wrong with the routing? I'm using devise without any custom modifications.
Thanks!
Wrong path helper:
$ rake routes
new_user_registration GET ... registrations#new
cancel_user_registration GET ... registrations#cancel
user_registration POST ... registrations#create
edit_user_registration GET ... registrations#edit
users PUT ... registrations#update # You want this one
DELETE ... registrations#destroy
Result:
<%= link_to "Grid", users_path(:user => {:project_view => 'grid'}), :method => :put, :confirm => "Are you sure?" %>
Update for your specific routes:
<%= link_to "Grid", registration_path(resource_name, :user => {:project_view => 'grid'}), :method => :put, :confirm => "Are you sure?" %>

Rails RoutingError: No route matches {:controller=>"sessions", :action=>"destroy"}

Yet when run rake:routes it appears to be there:
users GET /users(.:format) {:action=>"index", :controller=>"users"}
POST /users(.:format) {:action=>"create", :controller=>"users"}
new_user GET /users/new(.:format) {:action=>"new", :controller=>"users"}
edit_user GET /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET /users/:id(.:format) {:action=>"show", :controller=>"users"}
PUT /users/:id(.:format) {:action=>"update", :controller=>"users"}
DELETE /users/:id(.:format) {:action=>"destroy", :controller=>"users"}
sessions POST /sessions(.:format) {:action=>"create", :controller=>"sessions"}
new_session GET /sessions/new(.:format) {:action=>"new", :controller=>"sessions"}
session DELETE /sessions/:id(.:format) {:action=>"destroy", :controller=>"sessions"}
signup /signup(.:format) {:controller=>"users", :action=>"new"}
contact /contact(.:format) {:controller=>"pages", :action=>"contact"}
about /about(.:format) {:controller=>"pages", :action=>"about"}
help /help(.:format) {:controller=>"pages", :action=>"help"}
root /(.:format) {:controller=>"pages", :action=>"home"}
Here are the routes from routes.rb:
resources :users
resources :sessions, :only => [:new, :create, :destroy]
match '/signup', to: 'users#new'
match '/contact', to: 'pages#contact'
match '/about', to: 'pages#about'
match '/help', to: 'pages#help'
It's possible that you are not passing the :id param in your route, which is why the route is not matched, since :id is required:
session DELETE /sessions/:id(.:format) {:action=>"destroy", :controller=>"sessions"}
Note: The parentheses around the :format param mean that it is optional.
I got the same error as well.But the reason is the little mistake that in the view page I write
<%= form_for(:session,url:session_path) do |f| %>
which I less the last 's' of 'sessions'.
This looks like an error I was running into when running through http://ruby.railstutorial.org/, and it turned out that I had left a few things out of routes.rb. The addition of the resource route is accompanied by the following two additional routes:
match '/signin', :to => 'sessions#new'
match '/signout', :to => 'sessions#destroy'
It's hard to see because the first route in that group is already there, so I had just glossed over the group (several times) as already being there.
resources controller adds map to method
{:action=>"method", :controller=>"controller"}
when in your case the rails seemed to ask for explicitly the map as
{:controller=>“controller”, :action=>“method”}
The :controller is before :action
This also answered Noach's question why match '/signout', :to => 'sessions#destroy' has to exist, if you rake:routes you will see it added
{:controller=>“sessions”, :action=>“destroy”} while there is already a
{:action=>“destroy”, :controller=>“sessions”} added by resources sessions

Rails3 Routing Problem

I keep getting this error when trying to view a page.
ActionView::Template::Error (No route
matches {:controller=>"classifieds",
:action=>"edit", :id=>#}):
40: <%= h classified.category.name
%>
41: <%= h classified.subcategory.name
%>
42: <%= h classified.status %>
43: <%= link_to "Edit",
edit_classified_path(classified)%>
44: <%= link_to 'Destroy', classified,
:confirm => 'Are you sure?', :method
=> :delete %>
45: <%= check_box_tag 'remove[id][]',
classified.id, false %>
46:
routes file
Rails3::Application.routes.draw do
resources :main, :categories, :cities, :users, :subcategories, :classifieds
resource :user
root :to => 'main#index'
match ':controller(/:action(/:id(.:format)))'
# route for simple captcha
match '/simple_captcha/:action', :controller => 'simple_captcha'
#admin logout
match '/logout', :controller=>'users', :action=>'destroy'
match '/login', :controller=>'users', :action=>'show'
match '/adminsearch', :controller=>'classifieds', :action=>'adminsearch'
#search
match '/mainsearch', :controller=>'main', :action=>'mainsearch'
match '/:permalink_1/categorysearch', :controller=>'main', :action=>'categorysearch'
match '/contactadvertiser', :controller=>'main', :action=>'contactadvertiser'
#city page
match '/:permalink_1', :controller => 'main', :action => 'city'
match '/edit', :controller => 'cities', :action => 'edit'
#activate, edit classifieds
match '/activate/:activation_code', :controller => 'main', :action => 'activate'
match '/edit/:activation_code', :controller => 'classifieds', :action => 'edit'
match '/update/:activation_code', :controller => 'classifieds', :action => 'update'
match '/delete/:activation_code', :controller => 'classifieds', :action => 'destroy'
match '/classifieds/multidelete', :controller=>'classifieds', :action=>'delete_multiple'
#category page
match '/:permalink_1/:permalink_2', :controller => 'main', :action => 'category'
#ad page
match '/:permalink_1/:permalink_2/:permalink_3', :controller => 'classifieds', :action => 'show'
end
rake routes:
main_index GET /main(.:format) {:controller=>"main", :action=>"index"}
POST /main(.:format) {:controller=>"main", :action=>"create"}
new_main GET /main/new(.:format) {:controller=>"main", :action=>"new"}
edit_main GET /main/:id/edit(.:format) {:controller=>"main", :action=>"edit"}
main GET /main/:id(.:format) {:controller=>"main", :action=>"show"}
PUT /main/:id(.:format) {:controller=>"main", :action=>"update"}
DELETE /main/:id(.:format) {:controller=>"main", :action=>"destroy"}
categories GET /categories(.:format) {:controller=>"categories", :action=>"index"}
POST /categories(.:format) {:controller=>"categories", :action=>"create"}
new_category GET /categories/new(.:format) {:controller=>"categories", :action=>"new"}
edit_category GET /categories/:id/edit(.:format) {:controller=>"categories", :action=>"edit"}
category GET /categories/:id(.:format) {:controller=>"categories", :action=>"show"}
PUT /categories/:id(.:format) {:controller=>"categories", :action=>"update"}
DELETE /categories/:id(.:format) {:controller=>"categories", :action=>"destroy"}
cities GET /cities(.:format) {:controller=>"cities", :action=>"index"}
POST /cities(.:format) {:controller=>"cities", :action=>"create"}
new_city GET /cities/new(.:format) {:controller=>"cities", :action=>"new"}
edit_city GET /cities/:id/edit(.:format) {:controller=>"cities", :action=>"edit"}
city GET /cities/:id(.:format) {:controller=>"cities", :action=>"show"}
PUT /cities/:id(.:format) {:controller=>"cities", :action=>"update"}
DELETE /cities/:id(.:format) {:controller=>"cities", :action=>"destroy"}
users GET /users(.:format) {:controller=>"users", :action=>"index"}
POST /users(.:format) {:controller=>"users", :action=>"create"}
new_user GET /users/new(.:format) {:controller=>"users", :action=>"new"}
edit_user GET /users/:id/edit(.:format) {:controller=>"users", :action=>"edit"}
user GET /users/:id(.:format) {:controller=>"users", :action=>"show"}
PUT /users/:id(.:format) {:controller=>"users", :action=>"update"}
DELETE /users/:id(.:format) {:controller=>"users", :action=>"destroy"}
subcategories GET /subcategories(.:format) {:controller=>"subcategories", :action=>"index"}
POST /subcategories(.:format) {:controller=>"subcategories", :action=>"create"}
new_subcategory GET /subcategories/new(.:format) {:controller=>"subcategories", :action=>"new"}
edit_subcategory GET /subcategories/:id/edit(.:format) {:controller=>"subcategories", :action=>"edit"}
subcategory GET /subcategories/:id(.:format) {:controller=>"subcategories", :action=>"show"}
PUT /subcategories/:id(.:format) {:controller=>"subcategories", :action=>"update"}
DELETE /subcategories/:id(.:format) {:controller=>"subcategories", :action=>"destroy"}
classifieds GET /classifieds(.:format) {:controller=>"classifieds", :action=>"index"}
POST /classifieds(.:format) {:controller=>"classifieds", :action=>"create"}
new_classified GET /classifieds/new(.:format) {:controller=>"classifieds", :action=>"new"}
edit_classified GET /classifieds/:id/edit(.:format) {:controller=>"classifieds", :action=>"edit"}
classified GET /classifieds/:id(.:format) {:controller=>"classifieds", :action=>"show"}
PUT /classifieds/:id(.:format) {:controller=>"classifieds", :action=>"update"}
DELETE /classifieds/:id(.:format) {:controller=>"classifieds", :action=>"destroy"}
POST /user(.:format) {:controller=>"users", :action=>"create"}
GET /user/new(.:format) {:controller=>"users", :action=>"new"}
GET /user/edit(.:format) {:controller=>"users", :action=>"edit"}
GET /user(.:format) {:controller=>"users", :action=>"show"}
PUT /user(.:format) {:controller=>"users", :action=>"update"}
DELETE /user(.:format) {:controller=>"users", :action=>"destroy"}
root /(.:format) {:controller=>"main", :action=>"index"}
/:controller(/:action(/:id(.:format)))
/simple_captcha/:action(.:format) {:controller=>"simple_captcha"}
logout /logout(.:format) {:controller=>"users", :action=>"destroy"}
login /login(.:format) {:controller=>"users", :action=>"show"}
adminsearch /adminsearch(.:format) {:controller=>"classifieds", :action=>"adminsearch"}
mainsearch /mainsearch(.:format) {:controller=>"main", :action=>"mainsearch"}
/:permalink_1/categorysearch(.:format) {:controller=>"main", :action=>"categorysearch"}
contactadvertiser /contactadvertiser(.:format) {:controller=>"main", :action=>"contactadvertiser"}
/:permalink_1(.:format) {:controller=>"main", :action=>"city"}
edit /edit(.:format) {:controller=>"cities", :action=>"edit"}
/activate/:activation_code(.:format) {:controller=>"main", :action=>"activate"}
/edit/:activation_code(.:format) {:controller=>"classifieds", :action=>"edit"}
/update/:activation_code(.:format) {:controller=>"classifieds", :action=>"update"}
/delete/:activation_code(.:format) {:controller=>"classifieds", :action=>"destroy"} classifieds_multidelete /classifieds/multidelete(.:format) {:controller=>"classifieds", :action=>"delete_multiple"}
/:permalink_1/:permalink_2(.:format) {:controller=>"main", :action=>"category"}
/:permalink_1/:permalink_2/:permalink_3(.:format) {:controller=>"classifieds", :action=>"show"}
simple_captcha /simple_captcha/:id(.:format) {:controller=>"simple_captcha", :action=>"show"}
You want to do:
<%= link_to "Edit", edit_classified_path(:activation_code => classified)%>
or edit your routes.rb to:
match '/edit/:id', :controller => 'classifieds', :action => 'edit'
Your routes are very redundant and contradictory. First, try getting rid of the catch-all route:
match ':controller(/:action(/:id(.:format)))'
as it should not be used if you're using RESTful routes. If that doesn't help, let me know and I'll update my answer accordingly.
Further, all of your match routes are incorrect. They should follow the pattern:
match '/my_controller/:id' => 'my_controller#action'

devise 2 models 2 views problem with path

context:
rails 3.0.3
devise 1.1.5 and 1.2rc
i have following devise rdoc
rails g devise:install
rails g devise user
rails g devise employee
rails g devise:views users
rails g devise:views employees
routes.rb
devise_for :users
devise_for :employees, :path => 'admin'
devise.rb
config.scoped_views = true
rake routes gives
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session GET /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
user_unlock POST /users/unlock(.:format) {:action=>"create", :controller=>"devise/unlocks"}
new_user_unlock GET /users/unlock/new(.:format) {:action=>"new", :controller=>"devise/unlocks"}
GET /users/unlock(.:format) {:action=>"show", :controller=>"devise/unlocks"}
new_employee_session GET /admin/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
employee_session POST /admin/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_employee_session GET /admin/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
employee_password POST /admin/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_employee_password GET /admin/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_employee_password GET /admin/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /admin/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
a mailer views users or employees are
link_to 'Change my password', edit_user_password_url(#resource, :reset_password_token => #resource.reset_password_token)
link_to 'Change my password', edit_employee_password_url(#resource, :reset_password_token => #resource.reset_password_token)
But if i submit form i have this error (for user or employee)
TypeError in Devise/passwords#create
Showing /app/views/users/mailer/reset_password_instructions.html.erb where line #8 raised:
can't convert String into Hash
8: <%= link_to 'Change my password', edit_employee_password_url(#resource, :reset_password_token => #resource.reset_password_token) %>
if you have an idea ?
Initialy posted Mar 7 2011
The solution are in application_controller.rb.
add
ActionMailer::Base.default_url_options[:host] = "http://domain.com"