22 Jun '12, 8pm

芳本美代子も使ってるとの噂のSNS!すごいです・・・。 #sougofollow

> I am using subdomains in my application to control context. Therefor, > during user registration, password reset, and other actions that require > an email to be sent with a link to be clicked, I need to ensure that the > subdomain appropriate for the user is used. > > It seems I need to be able to access request.host from within an > ActionMailer model. But I am not clear how to do this. You'll have to supply the request object as a parameter to mailer calls made in your controllers. Here's an outline of one way to do this: class MyMailer < ActionMailer::Base def initialize(method_name, request, *params) @host = request.host_with_port super(method_name, *params) end def url_for(params) url_for_without_host(params.update(:host => @host)) end alias_method_chain :url_for, :host def doit(param1, param2) body :link => url_for(:controller => :user, :action => :rego) end end M...

Full article: http://www.ruby-forum.com/topic/175339