Anybody know why this isn't working for me?
On Oct 8, 12:36 pm, gaveeno <[EMAIL PROTECTED]> wrote:
> I'm using the Fetcher plugin which daemonizes polling the server for
> emails. When it pulls in an email, it passes it (the Net::Imap
> object) to the receive method of MailProcessor < ActionMailer::Base.
> The receive method then calls the process_message class method of
> IncomingMessage < ActiveRecord::Base, which should store the incoming
> message to the database as well as do a number of other things.
> However, this method does not seem to be getting executed for incoming
> emails. On the other hand, when this method is called from the
> controller containing the sms_inaction, the message gets processed/
> stored correctly. These are the methods in question:
>
> class MailProcessor < ActionMailer::Base
> def receive(mail)
> IncomingMessage.process_message({ :sender => mail.from,
> :subject => mail.subject,
> :channel => "email",
> :person_search_field => "email",
> :date => mail.date,
> :body => mail.body,
> :delivery_point => mail.to })
> end
>
> class MessengerController < ApplicationController
> def sms_in
> @incoming_message, @opt_or_feedback_object,@processing_notes =
> IncomingMessage.process_message({ :sender => params[:smsfrom],
> :subject => params[:smsmsg],
> :channel => "sms",
> :gateway_id => params[:smsid],
> :person_search_field => "mobile_phone",
> :date => params[:smsdate],
> :carrier => params[:network],
> :delivery_point => params[:smsto] })
> end
>
> class IncomingMessage < ActiveRecord::Base
> protected
> def self.process_message(msg_hash)
> @incoming_message = create_incoming_message
> #more code to process the message...I didn't paste it here
> because it calls
> #a number of other class methods and they would be too much to
> paste
> end
>
> def self.create_incoming_message
> IncomingMessage.create(:subject => @msg_hash[:subject],
> :person_id => "[EMAIL PROTECTED]",
> :body => @msg_hash[:body],
> :channel => @msg_hash[:channel],
> :gateway_id => @msg_hash[:gateway_id],
> :carrier => @msg_hash[:carrier],
> :date => @msg_hash[:date],
> :delivery_point_id => @delivery_point_id)
> end
>
> On Oct 8, 11:51 am, Frederick Cheung <[EMAIL PROTECTED]>
> wrote:
>
> > On 8 Oct 2008, at 16:34, gaveeno wrote:
>
> > > This is a little convoluted and I'm new to Rails, so please bear with
> > > me...
>
> > > My application needs to receive both SMS and emails. I have a
> > > controller that has a sms_in method, which receives SMS messages via a
> > > HTTP POST request from an SMS gateway. That controller then calls the
> > > IncomingMessage.process(args) method to go through a number of
> > > validations and create the incoming message in the database as well as
> > > various other database entries that are required with each incoming
> > > message. This works fine.
>
> > > However, I'm having trouble getting it to work for emails. In my
> > > MailProcessor (ActionMailer) receive method, I'm trying to pass
> > > similar arguments to the IncomingMessage.process(args) class method.
> > > However, for some reason this isn't working...I can't seem to call a
> > > class method for an ActiveRecord object from within the ActionMailer
> > > object, and I have no idea why!
>
> > That should work. Show what you're doing (and describe what you
> > actually mean by "isn't working")
>
> > Fred
>
> > > Any help would be greatly appreciated!
> > > -Gavin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---