Giter Club home page Giter Club logo

Comments (7)

cassiomarques avatar cassiomarques commented on August 18, 2024

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.

clippermadness avatar clippermadness commented on August 18, 2024

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.

cassiomarques avatar cassiomarques commented on August 18, 2024

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.

clippermadness avatar clippermadness commented on August 18, 2024

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.

cassiomarques avatar cassiomarques commented on August 18, 2024

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.

clippermadness avatar clippermadness commented on August 18, 2024

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_attr

include 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 => 2end

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] 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!


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.

cassiomarques avatar cassiomarques commented on August 18, 2024

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)

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.