Reputation: 6244
I am using CloudMailin in an attempt to upload profile pics to a mobile device web site via email. Using their documentation I have...
incoming_mails_controller.rb:
def create
...
user_id = params[:headers][:subject] # line 13
...
end
The error I am getting:
NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/incoming_mails_controller.rb:13:in `create'
The relevant portion of the log:
Apple-Mail=_...\r\n", "x_references"=>"[email protected]", "x_cc_header"=>"", "subject"=>"Smith, Joe"}
Rummaged around the web for a solution and didn't find a solution. Thanks for your help.
Placed the following in the controller:
::Rails.logger.info "PARAMS INSPECT: " + params.inspect
The following is only a very small portion of what it yielded:
PARAMS INSPECT: {"message"=>"Received: by ... :content-type:subject:date:message-id:to:mime-version:x-mailer\r\n...
Content-Type: multipart/alternative; boundary=\"Apple-Mail=_..."\r\n
Subject: Smith, John\r\n ...
"return_path"=>"[email protected]",
"x_from_header"=>"[\"[email protected]\"]", ...
"subject"=>"Smith, John"
Upvotes: 2
Views: 138
Reputation: 9700
It's hard to be certain of the exact structure of the params hash and any sub-hashes without the full (presumably long) print out of params, but it looks as though there's a parameter for each header, including a 'subject' parameter (params[:subject]
, probably?). Is that what you needed?
Upvotes: 2