-
Notifications
You must be signed in to change notification settings - Fork 155
Error when Model.new with attributes #152
Comments
This is because you are failing to call If the problem persists after calling |
it works! thanks!! |
Could you please advise on where exactly within the Rails app DataMapper.finalize should be called? Can it be called multiple times (ie. at the bottom of every model file), once from inside an initializer, application.rb, etc.? |
Hi disbelief
* if the model has a relationship to another model that hasn't been required yet, it will blow up** |
As far as I know :
|
@namelessjon I've got something like what you've described working now. I created a DataMapper initializer that requires all of my Model files first, then calls DataMapper.finalize. I heed your warning about things blowing up if the Models require files that haven't been included yet. @mbj thanks for the info. I'm actually not using the dm-rails gem at the moment. I'm going to check it out now. |
This will also happen when cache_classes = false in Rails. Which obviously makes testing and development rather tiresome. |
@pdf Did you find a way around that in development environment? |
@jaischeema Only by explicitly calling |
Error when Model.new with attributes
because of commit: afbd387
model.allowed_writer_methods is nil
stack trace:
NoMethodError:
undefined method
include?' for nil:NilClass # /Users/yayugu/.rvm/gems/ruby-1.9.2-p290/bundler/gems/dm-core-6031e6ef3ee8/lib/dm-core/resource.rb:332:in
block in attributes='# /Users/yayugu/.rvm/gems/ruby-1.9.2-p290/bundler/gems/dm-core-6031e6ef3ee8/lib/dm-core/resource.rb:329:in
each' # /Users/yayugu/.rvm/gems/ruby-1.9.2-p290/bundler/gems/dm-core-6031e6ef3ee8/lib/dm-core/resource.rb:329:in
attributes='# /Users/yayugu/.rvm/gems/ruby-1.9.2-p290/bundler/gems/dm-core-6031e6ef3ee8/lib/dm-core/resource.rb:748:in
initialize' # ./spec/user_spec.rb:7:in
new'# ./spec/user_spec.rb:7:in `block (3 levels) in <top (required)>'
code:
user.rb
# encoding: utf-8
class User
include DataMapper::Resource
user_spec.rb
when rollback to
if model.public_method_defined?(setter = "#{name}=")
it works fine.
The text was updated successfully, but these errors were encountered: