Comments (7)
Hello,
Did you mistyped the ThingWithEnum has_enumeration_for declaration? It's using the state
attribute, but on the rails console you used a test
attribute.
If it was just a typing mistake, I will install the same versions you are using in your app and try to reproduce the problem.
Thanks
from enumerate_it.
Hi Cassio,
It's not a mistake. I'm just demonstrating that updated_at gets suppressed
even when setting some arbitrary attribute on the model class, not just the
enumerated attribute. "test" is a column in the "things" table.
Rich
On Wed, Oct 24, 2012 at 6:03 PM, Cássio Marques [email protected]:
Hello,
Did you mistyped the ThingWithEnum has_enumeration_for declaration? It's
using the state attribute, but on the rails console you used a testattribute.If it was just a typing mistake, I will install the same versions you are
using in your app and try to reproduce the problem.Thanks
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-9762778.
Rich Sutton
CTO / VP of Engineering
socialiqnetworks.com
mobile 714-318-7737
from enumerate_it.
Could you please provide the exact Rails/ActiveSupport version you are using? I think that bundle show rails / bundle show activesupport will do.
Thanks
from enumerate_it.
Sure.
$ bundle show rails
/usr/local/rvm/gems/ruby-1.9.2-p320/gems/rails-3.2.8
$ bundle show activesupport
/usr/local/rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.8
Rich
On Wed, Oct 24, 2012 at 6:15 PM, Cássio Marques [email protected]:
Could you please provide the exact Rails/ActiveSupport version you are
using? I think that bundle show rails / bundle show activesupport will do.Thanks
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-9762955.
Rich Sutton
CTO / VP of Engineering
socialiqnetworks.com
mobile 714-318-7737
from enumerate_it.
Hello,
Please help me investigate this. I tried to reproduce your problem but I couldn't. Take a look at what I've done:
class ThingWithEnum < ActiveRecord::Base
attr_accessible :enumerated_attr, :other_attr
include EnumerateIt
has_enumeration_for :enumerated_attr, :with => MyEnum, :create_helpers => true, :create_scopes => true
end
class MyEnum < EnumerateIt::Base
associate_values :value_1 => 1, :value_2 => 2
end
# Rails Console
1.9.2-p320 :001 > thing = ThingWithEnum.new :enumerated_attr => MyEnum::VALUE_1, :other_attr => 10
=> #<ThingWithEnum id: nil, enumerated_attr: 1, other_attr: 10, created_at: nil, updated_at: nil>
1.9.2-p320 :002 > thing.save
(0.1ms) begin transaction
SQL (49.9ms) INSERT INTO "thing_with_enums" ("created_at", "enumerated_attr", "other_attr", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Thu, 25 Oct 2012 13:16:36 UTC +00:00], ["enumerated_attr", 1], ["other_attr", 10], ["updated_at", Thu, 25 Oct 2012 13:16:36 UTC +00:00]]
(1.3ms) commit transaction
=> true
1.9.2-p320 :003 > thing.other_attr = 20
=> 20
1.9.2-p320 :004 > thing.save
(0.1ms) begin transaction
(0.3ms) UPDATE "thing_with_enums" SET "other_attr" = 20, "updated_at" = '2012-10-25 13:16:58.453857' WHERE "thing_with_enums"."id" = 1
(2.0ms) commit transaction
=> true
Using MRI 1.9.2-p320, Rails 3.2.8 and enumerate_it 0.7.17, on a fresh new Rails app.
Maybe this is being caused by some other gem that you are using? What would be the exact steps needed to reproduce your problem?
Thanks!
from enumerate_it.
Those steps should have done it. It could very well be an interaction with
some other gem, since our Rails app is big, has lots of gem dependencies
and has gone through many upgrade cycles. Seems like I need to debug it in
my environment.
Do you know where Rails sets updated_at on a save?
Rich
On Thu, Oct 25, 2012 at 6:22 AM, Cássio Marques [email protected]:
Hello,
Please help me investigate this. I tried to reproduce your problem but I
couldn't. Take a look at what I've done:class ThingWithEnum < ActiveRecord::Base
attr_accessible :enumerated_attr, :other_attrinclude EnumerateIt
has_enumeration_for :enumerated_attr, :with => MyEnum, :create_helpers => true, :create_scopes => trueend
class MyEnum < EnumerateIt::Base
associate_values :value_1 => 1, :value_2 => 2endRails Console
1.9.2-p320 :001 > thing = ThingWithEnum.new :enumerated_attr => MyEnum::VALUE_1, :other_attr => 10
=> #<ThingWithEnum id: nil, enumerated_attr: 1, other_attr: 10, created_at: nil, updated_at: nil>
1.9.2-p320 :002 > thing.save
(0.1ms) begin transaction
SQL (49.9ms) INSERT INTO "thing_with_enums" ("created_at", "enumerated_attr", "other_attr", "updated_at") VALUES (?, ?, ?, ?) ["created_at", Thu, 25 Oct 2012 13:16:36 UTC +00:00], ["enumerated_attr", 1], ["other_attr", 10], ["updated_at", Thu, 25 Oct 2012 13:16:36 UTC +00:00] commit transaction
=> true
1.9.2-p320 :003 > thing.other_attr = 20
=> 20
1.9.2-p320 :004 > thing.save
(0.1ms) begin transaction
(0.3ms) UPDATE "thing_with_enums" SET "other_attr" = 20, "updated_at" = '2012-10-25 13:16:58.453857' WHERE "thing_with_enums"."id" = 1
(2.0ms) commit transaction
=> trueUsing MRI 1.9.2-p320, Rails 3.2.8 and enumerate_it 0.7.17, on a fresh new
Rails app.Maybe this is being caused by some other gem that you are using? What
would be the exact steps needed to reproduce your problem?Thanks!
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-9777163.
Rich Sutton
CTO / VP of Engineering
socialiqnetworks.com
mobile 714-318-7737
from enumerate_it.
There is a ActiveRecord::Timestamp
module that gets included inside ActiveRecord classes. As far as I can tell, it overrides the original save
and update
implementations, settings the created_at and updated_at attributes and then calling super
. It lives inside activerecord/lib/active_record/timestamp.rb.
from enumerate_it.
Related Issues (20)
- Quick question on EnumerateIt HOT 8
- Always order by enumerate values name when using list HOT 4
- How to specify custom message for validates_inclusion_of or disable validates_inclusion_of all together? HOT 1
- Deprecation Warning with Rails 5.0.0.beta3 HOT 6
- Set a value to always be at the end of sorted list HOT 2
- Translate is not working with namespaced enumeration HOT 5
- Symbols for enumeration with spaces HOT 1
- List values of the enumeration HOT 1
- Allow to associate new values after they are already associated HOT 2
- Can enumerate_it be used with postgresql enum types? HOT 2
- Extending existing enumerations HOT 2
- Can enumeration be casted to hash? HOT 1
- Translate enumeration value to associated polymorphic instance HOT 2
- `has_enumeration_for` with default value HOT 2
- Set default options for has_enumeration_for HOT 3
- Official support for Rails 6 HOT 2
- Rails generator should humanize enum key for default I18n value
- Could not generate field 'single' with unknown type '1'. HOT 2
- Generator isn't working for array values
- Type Object is not instantiated until there is a value in the attribute it is targeting? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enumerate_it.