GithubHelp home page GithubHelp logo

simple_model's People

Contributors

joshmckin avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

simple_model's Issues

undefined method `attribute'

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.