pluginaweek / enumerate_by Goto Github PK
View Code? Open in Web Editor NEWAdds support for declaring an ActiveRecord class as an enumeration
Home Page: http://www.pluginaweek.org
License: MIT License
Adds support for declaring an ActiveRecord class as an enumeration
Home Page: http://www.pluginaweek.org
License: MIT License
Emmanuel Nicolau opened this issue
If there is a model in a plugin thats get loaded before enumerate_by (like Tag in acts-as-taggable-on), then a call to Tag.new.to_xml raise this error:
NoMethodError: You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:97:in enumeration_association_for’ from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:63:in
serializable_attribute_names’
from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:63:in map!’ from /Users/Emma/Code/prueba/vendor/plugins/enumerate_by/lib/enumerate_by/extensions/serializer.rb:63:in
serializable_attribute_names’
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:199:in serializable_attributes’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:210:in
add_attributes’
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:271:in serialize’ from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in
call’
from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in _nested_structures’ from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:58:in
method_missing’
from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:31:in tag!’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:270:in
serialize’
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serialization.rb:93:in to_s’ from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/serializers/xml_serializer.rb:156:in
to_xml’
from (irb):1
This ticket has 0 attachment(s).
Emmanuel Nicolau opened this issue
@@@ ruby
uninitialized constant ActiveRecord::Serialization::Serializer
/Users/Emma/.rvm/gems/ruby-1.9.2-rc2/gems/enumerate_by-0.4.4/lib/enumerate_by/extensions/serializer.rb:115:in <top (required)>’ /Users/Emma/.rvm/gems/ruby-1.9.2-rc2/gems/enumerate_by-0.4.4/lib/enumerate_by.rb:3:in
<top (required)>’
/Users/Emma/.rvm/gems/ruby-1.9.2-rc2/gems/bundler-1.0.0.rc.2/lib/bundler/runtime.rb:64:in require’ /Users/Emma/.rvm/gems/ruby-1.9.2-rc2/gems/bundler-1.0.0.rc.2/lib/bundler/runtime.rb:64:in
block (2 levels) in require’
/Users/Emma/.rvm/gems/ruby-1.9.2-rc2/gems/bundler-1.0.0.rc.2/lib/bundler/runtime.rb:62:in each’ /Users/Emma/.rvm/gems/ruby-1.9.2-rc2/gems/bundler-1.0.0.rc.2/lib/bundler/runtime.rb:62:in
block in require’
/Users/Emma/.rvm/gems/ruby-1.9.2-rc2/gems/bundler-1.0.0.rc.2/lib/bundler/runtime.rb:51:in each’ /Users/Emma/.rvm/gems/ruby-1.9.2-rc2/gems/bundler-1.0.0.rc.2/lib/bundler/runtime.rb:51:in
require’
/Users/Emma/.rvm/gems/ruby-1.9.2-rc2/gems/bundler-1.0.0.rc.2/lib/bundler.rb:114:in `require’
...
@@@
This ticket has 0 attachment(s).
I've done a bit of digging and construct_attributes_from_arguments was deprecated from ActiveRecord::Base in version 3.0.9 (http://apidock.com/rails/ActiveRecord/Base/construct_attributes_from_arguments/class). I'm still digging to determine what the method was changed to or where it was moved. I'm curious though if someone might already have a solution for this issue.
Paweł Kondzior opened this issue
In rails 2.3.1 simple model with is acting as enumeration can’t handle case when there is no table in db, example:
@@@
class TicketStatus < ActiveRecord::Base
acts_as_enumeration
end
@@@
in console
@@@
TicketStatus
=> TicketStatusTable doesnt exist
@@@
And fallowing errors in log:
Mysql::Error: Table ’servicedesk3_production.ticket_statuses’ doesn’t exist: SHOW FIELDS FROM ticket_statuses
This ticket has 0 attachment(s).
Emmanuel Nicolau opened this issue
@@@ ruby
class Car < ActiveRecord::Base
has_many :wheel_types
end
class WheelType < ActiveRecord::Base
enumerate_by :name
bootstrap(
{:id => 1, :name => ’big’},
{:id => 2, :name => ’small’}
)
end
Car.create.reload.wheel_types.frozen?
=> true
@@@
This happens with has_many :through too.
This ticket has 0 attachment(s).
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.