joshmckin / simple_model Goto Github PK
View Code? Open in Web Editor NEWQuick models for forms and webservices
License: MIT License
Quick models for forms and webservices
License: MIT License
Hi Josh,
Something changed between version 1.2.3 and 1.2.5 to cause my specs to now fail.
I'm getting a NoMethodError -- undefined method `attribute' when calling valid? on a model instance. This happens for a few different models. For example:
class ProfileNotice < Notice
has_attribute :item_type
has_attribute :item_id
has_attribute :name
has_attribute :url
has_int :c_percent
has_attribute :c_hint
# minimum reqs for a profile notice
validates_presence_of :item_type, :item_id
validates_format_of :item_id, :with => /^[0-9a-f]{24}$/
#validates_presence_of :name
#validates_presence_of :url
validates_numericality_of :c_percent, :only_integer => true, :allow_nil => true, :greater_than_or_equal_to => 0, :less_than_or_equal_to => 100
end
class ProfileChangeNotice < ProfileNotice
has_attribute :old_name
has_attribute :edits
end
Here's a backtrace (abbreviated):
ERROR -- : Processing users: [NoMethodError] undefined method `attribute' for #<Notices::ModerationNotice:0x000000018cddf8>
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/attribute_methods.rb:407:in `method_missing'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/attribute_methods.rb:345:in `item_type'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/errors.rb:254:in `block in add_on_blank'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/errors.rb:253:in `each'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/errors.rb:253:in `add_on_blank'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/validations/presence.rb:8:in `validate'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:310:in `_callback_before_1'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:407:in `_run__3590345554886525909__validate__900521696682588847__callbacks'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_validate_callbacks'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/validations.rb:228:in `run_validations!'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/validations/callbacks.rb:53:in `block in run_validations!'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:403:in `_run__3590345554886525909__validation__900521696682588847__callbacks'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_validation_callbacks'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.11/lib/active_model/validations.rb:195:in `valid?'
/home/dpellegrini/.rvm/gems/ruby-1.9.3-p327/gems/notices-0.0.9/lib/notices/mongo_client.rb:26:in `submit_user_email_notice'
Ideas?
Thanks!
David
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.