Mange / roadie-rails

Making HTML emails comfortable for the Rails rockstars
MIT License
363 stars 65 forks source link

TypeError: can't define singleton #13

Closed hayesgm closed 10 years ago

hayesgm commented 10 years ago

I'm getting the following error when trying to send a message: TypeError: can't define singleton. I'm attempting to updating from roadie 2.0 to roadie-rails, but this is a blocker. I'm using rails 4.0.8. Also, I'm using the sendgrid gem which is present in the backtrace.

Code

UserMailer.my_letter().deliver

Backtrace

from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:6:in `extend_object'
from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:6:in `extend'
from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:6:in `block in mail'
from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:5:in `tap'
from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:5:in `mail'
from /Users/.rvm/gems/ruby-2.0.0-p247/gems/sendgrid-1.2.0/lib/sendgrid.rb:168:in `mail'
from /Users/code/project/app/mailers/user_mailer.rb:52:in `my_letter'

Thanks for help getting this fixed.

Mange commented 10 years ago

That's weird. It's saying that Roadie cannot extend the Mail object for some reason. You could go with a manual Mailer for moment if you want to upgrade. I'll take a look in the meantime. Den 22 jul 2014 08:22 skrev "Geoff Hayes" notifications@github.com:

I'm getting the following error when trying to send a message: TypeError: can't define singleton. I'm attempting to updating from roadie 2.0 to roadie-rails, but this is a blocker. I'm using rails 4.0.8. Also, I'm using the sendgrid gem which is present in the backtrace.

Code

UserMailer.my_letter().deliver

Backtrace

from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:6:in extend_object' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:6:inextend' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:6:in block in mail' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:5:intap' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:5:in mail' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/sendgrid-1.2.0/lib/sendgrid.rb:168:inmail' from /Users/code/project/app/mailers/user_mailer.rb:52:in `my_letter'

Thanks for help getting this fixed.

— Reply to this email directly or view it on GitHub https://github.com/Mange/roadie-rails/issues/13.

Mange commented 10 years ago

Hmm, could it be that your Mailer method isn't returning an instance of Mail, but rather a symbol, numeric, true, false, nil or something similar? Perhaps you could inject a small p mail in the line of the exception to see what it is. Den 22 jul 2014 19:10 skrev "Magnus Bergmark" magnus.bergmark@gmail.com:

That's weird. It's saying that Roadie cannot extend the Mail object for some reason. You could go with a manual Mailer for moment if you want to upgrade. I'll take a look in the meantime. Den 22 jul 2014 08:22 skrev "Geoff Hayes" notifications@github.com:

I'm getting the following error when trying to send a message: TypeError: can't define singleton. I'm attempting to updating from roadie 2.0 to roadie-rails, but this is a blocker. I'm using rails 4.0.8. Also, I'm using the sendgrid gem which is present in the backtrace.

Code

UserMailer.my_letter().deliver

Backtrace

from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:6:in extend_object' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:6:inextend' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:6:in block in mail' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:5:intap' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/roadie-rails-1.0.2/lib/roadie/rails/automatic.rb:5:in mail' from /Users/.rvm/gems/ruby-2.0.0-p247/gems/sendgrid-1.2.0/lib/sendgrid.rb:168:inmail' from /Users/code/project/app/mailers/user_mailer.rb:52:in `my_letter'

Thanks for help getting this fixed.

— Reply to this email directly or view it on GitHub https://github.com/Mange/roadie-rails/issues/13.

hayesgm commented 10 years ago

@Mange Yeah, I was going to do that to see what could be causing this.

hayesgm commented 10 years ago

I added p email in Roadie::Rails::Automatic module:

def mail(*args, &block)
  super.tap do |email|
    p email
    email.extend InlineOnDelivery
    email.roadie_options = roadie_options.try(:dup)
  end
end

Result

:user_mailer

So the question is how that is coming up as the response.

I tried removing the sendgrid gem, as well as all other includes, default and interceptors to no avail.

Mange commented 10 years ago

That's really weird! Maybe you could trace it from Rails' source code? What does your Mailer method look like? It might be an option you are passing that causes it. If you were to remove the Automatic module and print the result of the #mail call, do you get a proper email? If so, Roadie must be the one to blame. Den 22 jul 2014 21:00 skrev "Geoff Hayes" notifications@github.com:

I added p email in Roadie::Rails::Automatic module:

def mail(*args, &block) super.tap do |email| p email email.extend InlineOnDelivery email.roadie_options = roadie_options.try(:dup) end end

Result :user_mailer

So the question is how that is coming up as the response.

I tried removing the sendgrid gem, as well as all other includes, default and interceptors to no avail.

— Reply to this email directly or view it on GitHub https://github.com/Mange/roadie-rails/issues/13#issuecomment-49784776.

Mange commented 10 years ago

Closing until I get more information. Anyone else with this issue, please speak up.