Skip to content

Problem with :locale URL prefix and Confirmable module #815

Closed
szimek opened this Issue Jan 27, 2011 · 5 comments

3 participants

@szimek
szimek commented Jan 27, 2011

Hey,

I tried setting up :locale prefix in my app like this:

scope "/:locale" do
  devise_for :users
  resources :posts
end

but the problem is that after signing up, when rendering the default app/views/devise/mailer/confirmation_instructions.html.erb template I get the following error:

ActionView::Template::Error (No route matches {:action=>"create", :controller=>"devise/confirmations", :confirmation_token=>"ziy2Zmxk86wIzPnuupyJB0SBGxfG5CThpTx4RRmWzkajWqCL0EstkMLvVoUz"}):
    2:
    3: <p>You can confirm your account through the link below:</p>
    4:
    5: <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>

Seems like there's some problem with confirmation_url...

@josevalim
Plataformatec member

Yes, you need to copy the views to your application and change the confirmation_url (and all other calls) to pass the locale as parameter. Another option is to configure default_url_options to include :locale. There is probably something in the wiki, if not, check Rails documentation.

@szimek
szimek commented Jan 27, 2011

Man, you're fast! :)

I already got default_url_options set like this in my application controller:
def default_url_options(options={})
{ :locale => I18n.locale }
end
Other URLs work fine with :locale prefix (posts, registration etc.) Do I still need to copy Devise views and manually pass locale to Devise URLs?

@josevalim
Plataformatec member

You also need to set it in ActionMailer::Base or Devise::Mailer, since they don't inherit this setting from the controller.

@szimek
szimek commented Jan 27, 2011

Right... Thanks!

@gnagno
gnagno commented Oct 12, 2011

Hello,

sorry for posting in a closed issue, but I am having the same problem as szimek.

my routing file looks like the one in the first post, then I added:

  class Devise::Mailer
    def default_url_options(options={})
      { :locale => I18n.locale }
    end
  end

to my application.rb, now if I try to signin what I get is:

NoMethodError in Devise::RegistrationsController#create

undefined method `confirmation_instructions' for Devise::Mailer:Class

thank you for any help,

Gnagno

@apardo apardo referenced this issue in alabs/oigame Sep 16, 2012
Closed

Bug al crear un usuario #70

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.