2013-03-18 61 views
3

設計confirmation_url是無域,如生產只是一個相對URL:設計確認鏈接丟失域

http://users/confirmation?confirmation_token=... 

我試圖改變

confirmation_url(@resources, :confirmation_token => @resource.confirmation_token) 

confirmation_url(:confirmation_token => @resource.confirmation_token) 

但產生相同的網址。我升級到設計2.2.3,但結果相同。 Rails的3.1.4

更新: 我在production.rb設置:

config.action_mailer.default_url_options = { :host => 'mysubdomain.mysite.com' } 

,我試圖在應用控制器設置

before_filter set_actionmailer_host 

    def set_actionmailer_host 
     ActionMailer::Base.default_url_options[:host] = request.host_with_port 
    end 

無濟於事(https://github.com/plataformatec/devise/issues/1567

更新: 這發生在開發和生產中。

更新 爲什麼設計沒有在應用程序/視圖中使用模板我無法理解/色器件/郵件/ confirmation_instructions.html.haml如果我能編輯,我可以手動添加主機:'http://mysite.com/' + confirmation_url(... 我嘗試設置範圍視圖設置,但它沒有任何影響 這是一場災難,用戶無法確認其註冊:(

回答

4

您可能錯過了將默認url主機添加到您的環境配置文件。當您運行rails g devise:install命令時,您通常會收到這些說明。

# config/environments/development.rb 

# Default actiomailer url host (required by devise) 
config.action_mailer.default_url_options = { host: 'myapp.dev' } 

您需要在所有環境中使用此設置。

# config/environments/production.rb 

# Default actiomailer url host (required by devise) 
config.action_mailer.default_url_options = { host: 'myproductionapp.com' } 
+0

參數:host_only實際上已在confirmation_url調用中設置,這導致了問題 – rigyt 2013-03-19 13:02:21