syntax error, unexpected ':', expecting '='
...l: subscribe_email, subscribe: true) }
class Subscription < ActiveRecord::Base
before_save { self.email = email.downcase}
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, :presence=> true, :format=> VALID_EMAIL_REGEX, :uniqueness=> {:if=> :subscribe_on?}
scope :subscribe_on, lambda(self.email){ where(:email=> self.email, :subscribe=> true) }
def subscribe_on?
#subs = Subscription.select('subscribe').where(:email=>self.email).first
subs = self.class.subscribe_on
logger.debug "subscribe_on subs-: #{subs}"
subs.first
end
end
NoMethodError (undefined method `email' for #
db:schema:dump
для содания актуальной shema.rb CREATE TABLE IF NOT EXISTS `subscriptions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`subscribe` tinyint(1) NOT NULL DEFAULT '0',
`created_at` datetime NOT NULL,
`ip` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=103 ;
class Subscription < ActiveRecord::Base
before_save { self.email = email.downcase}
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, :presence=> true,
:format=> VALID_EMAIL_REGEX,
#:uniqueness=> true
:uniqueness=> {:if=> :subscribe_on?}
def subscribe_on?
#subs = Subscription.select('subscribe').where(:email=>self.email).first
subs = Subscription.find_by(:email => self.email).subscribe
logger.debug "subscribe_on subs-: #{subs}"
end
end
NoMethodError (undefined method `find_by' for #<Class:0x7f9954808690>):
Processing by SubscribtionsController#validate as JSON
Parameters: {"subscribtion"=>{"email"=>"no@ma.ru"}}
Для андрюши нужен отдельный пульт + доп. траты на саму приставку, что усложняет все.