Monday 15 February 2010

ruby on rails - NoMethodError - undefined method `by_email' for ActiveModel::MassAssignmentSecurity::BlackList:Class: -


I have an email_ address object that I am trying to see if the blacklist is for that particular domain . I'm calling it this way:

  elsif @ email.blacklisted? (@ Domain.id) Do something ... end   

I am getting the error: NoMethodError - Undefined for 'by_email' for ActiveModel Method :: MassAssignmentSecurity :: BlackList: Class:

I have also tried to make a .find_all_by_id that's the same error instead of using the blacklist scope I created although this is driving me crazy No idea would be amazing!

Email address class

  class email address & lt; ActiveRecord :: Base Attr_accessible: Email ,: global_blacklist has_many: Transaction is_mahmed: black_lists has has_many: opt_outs validates: email,: appearance = & gt; True ,: Specification = & gt; Correct confirmation: global_blacklist, acceptance = & gt; True df blacklisted? (Domain_id) black_lists = BlackList.by_email (self.id) .by_domain (domain_id) black_lists.count & gt; 0 End End   

Blacklist Class

  Class Blacklist & lt; ActiveRecord :: Base attr_accessible: domain_id ,: email_address_id ,: date_added belong_to: domain is_to: email_address validates: domain_id ,: presence = & gt; Correct confirmation: email_address_id ,: presence = & gt; Correct confirmation: date_added ,: presence = & gt; True is GLOBAL_BLACK_LIST_THRESHOLD = 2 Regions: by_domain, - & gt; (Domain_id) {where ('domain_id =?', Domain_id)} Scope: by_email, - & gt; (Email_id) {where ('email_address_id =?', Email_id}}    

just any And the problem is ...

Class name blacklist (Capital L) seems to be an active-modal class name.

I changed the class name to blacklist (one word instead of two) and the problem went away.

No comments:

Post a Comment