Forum: Ruby on Rails ActionMailer template gets nil param from non-nil deliver_

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fritz A. (Guest)
on 2008-10-18 00:40
Rails 1.2.6
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]

=Summary:

I pass a non-nil parameter to an ActionMailer class's deliver_* method.
The corresponding * instance method for the ActionMailer gets a nil
instead. Disaster ensues.

Will someone please tell me what I'm doing wrong?

=Details:

I have an ActionMailer::Base class with the following template method:

  def request(req)
     # Control reaches here. req is logged as nil:
     logger.info "in MyMailer#request, request = #{req.inspect}"

    # Exception in the following, owing to the nil:
    subject "Request for authsmtp exception (#{req.permit_ip})"
    # etc.
  end

This is invoked through this method in my ActionController::Base class:

  def create
    @permission = Permission.new(params[:permission])
    if @permission.save
       # @permission is non-nil, and as expected, in the following log:
       logger.info "In PermissionsController#create, @permission =
#{@permission.inspect}"
       MyMailer.deliver_request(@permisssion)   # Mail the request to
approvers.
      # etc.
    end
  end

As noted in the comments, @permission is non-nil when passed to
deliver_request(). In request(), the corresponding parameter, req, is
nil. I am stymied.

I have searched the archives, and nothing obvious presents itself. Will
someone please help me get started again?

(This is my first post through this forum software. I am hoping it
doesn't destroy linebreaks or indentation. If they do get clobbered, I
apologize, and would like to know how not to get them clobbered.)

    — F
Fritz A. (Guest)
on 2008-10-20 18:59
Fritz A. wrote:
> Rails 1.2.6
> ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
>
> =Summary:
>
> I pass a non-nil parameter to an ActionMailer class's deliver_* method.
> The corresponding * instance method for the ActionMailer gets a nil
> instead. Disaster ensues.

Never mind. The cause was a typo in my own code, and my (apparently
failing) eyes never managed to see it.

Thanks for the attention of whomever paid attention.

    — F
This topic is locked and can not be replied to.