0

I want to create a PageMailer which emails users when someone interacts with one of their pages.

The User has_many pages, and so the page email is defined as user.email

I have tried attr_reader in the Page model, and also I've declared an email method, neither are currently working

I'm getting an error message which states: undefined method 'email' for <Page:0x512000d4>

Can anyone suggest a simple workaround?

thanks

Paul

Taryn East
  • 27,486
  • 9
  • 86
  • 108
Paul Nelligan
  • 2,015
  • 2
  • 18
  • 18

1 Answers1

0
send_fb_like_email(user, page)
undefined method 'email' for <Page:0x512000d4>

The error says it's trying to find the "email" of a "page". Looks like you've accidentally switched the user and page params in one of the calls to the method. Go check all the places where you call this email method and see if you've done that.

Taryn East
  • 27,486
  • 9
  • 86
  • 108
  • Hi Taryn, that's not actually the case ... I had previously tried a 'page_mailer' with just one param - a page object ... It was telling me that email was not a method of Page, when it clearly was! – Paul Nelligan Dec 20 '11 at 17:45
  • is it a method of Page (the class) or of *a* page (ie an instance of Page) ? – Taryn East Dec 20 '11 at 17:50
  • Also - please note, I can only comment based on the code that you actually show us... and the code that you have actually showed us show that it's trying to access email from a user object, not a page object, and that the error is that it's trying to access email form a page object. – Taryn East Dec 20 '11 at 17:52