每次我尝试在视图中使用Datetime_select时,应用程序都会抛出属性错误.
Mongoid::Errors::UnknownAttribute:
Problem:
Attempted to set a value for 'fromtime(1i)' which is not allowed on the model Event.
Summary:
Without including Mongoid::Attributes::Dynamic in your model and the attribute does not already exist in the attributes hash, attempting to call Event#fromtime(1i)= for it is not allowed. This is also triggered by passing the attribute to any method that accepts an attributes hash, and is raised instead of getting a NoMethodError.
Resolution:
You can include Mongoid::Attributes::Dynamic if you expect to be writing …
Run Code Online (Sandbox Code Playgroud) 我似乎在使用FactoryGirl创建Time对象时遇到了一些麻烦.当我这样做:
factory :invite do |n|
fromtime Time.now + 1.weeks
totime Time.now + 1.weeks + 1.hour
end
Run Code Online (Sandbox Code Playgroud)
工厂工作正常,但我希望有许多顺序的邀请.所以当我这样做时:
factory :invite do |n|
fromtime Time.now + n.weeks
totime Time.now + n.weeks + 1.hour
end
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
/Users/jamesstrocel/.rvm/gems/ruby-2.0.0-p0@gameplaydate/gems/activesupport-3.2.13/lib/active_support/core_ext/time/calculations.rb:312:in `+': can't convert FactoryGirl::Declaration::Implicit into an exact number (TypeError)
from /Users/jamesstrocel/.rvm/gems/ruby-2.0.0-p0@gameplaydate/gems/activesupport-3.2.13/lib/active_support/core_ext/time/calculations.rb:312:in `plus_with_duration'
from /Users/jamesstrocel/rails/gameplaydate/spec/factories.rb:24:in `block (2 levels) in <top (required)>'
from /Users/jamesstrocel/.rvm/gems/ruby-2.0.0-p0@gameplaydate/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:18:in `instance_eval'
from /Users/jamesstrocel/.rvm/gems/ruby-2.0.0-p0@gameplaydate/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:18:in `factory'
from /Users/jamesstrocel/rails/gameplaydate/spec/factories.rb:22:in `block in <top (required)>'
from /Users/jamesstrocel/.rvm/gems/ruby-2.0.0-p0@gameplaydate/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:49:in `instance_eval'
from /Users/jamesstrocel/.rvm/gems/ruby-2.0.0-p0@gameplaydate/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:49:in `run'
from /Users/jamesstrocel/.rvm/gems/ruby-2.0.0-p0@gameplaydate/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:7:in `define'
from /Users/jamesstrocel/rails/gameplaydate/spec/factories.rb:1:in `<top (required)>'
from …
Run Code Online (Sandbox Code Playgroud)