Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with default value #48

Closed
maurcarvalho opened this issue Nov 17, 2014 · 7 comments
Closed

Problem with default value #48

maurcarvalho opened this issue Nov 17, 2014 · 7 comments

Comments

@maurcarvalho
Copy link

When run in rails console, It's normal do happen this?

Point.new
NoMethodError: super: no superclass method `transaction_type=' for #Point:0x00000101913578

My Point definition

class Point < ActiveRecord::Base
    include ClassyEnum::ActiveRecord
  classy_enum_attr :transaction_type, default: 'issuance'
    delegate :do, to: :transaction_type
  belongs_to :loyalty
end
}
class TransactionType < ClassyEnum::Base
    owner :point
end

class TransactionType::Issuance < TransactionType
    def do
        point.loyalt.balance+=point.val
    end 
end

class TransactionType::Redemption < TransactionType
    def do
        point.loyalt.balance-=point.val
    end 
end

I'm following the README file and this should work..

May someone help me?

@beerlington
Copy link
Owner

Do you have a column on your points table for transaction_type? If so, maybe you need to reload the console?

@beerlington
Copy link
Owner

Unrelated, but you have a typo in your enums too, point.loyalt.balance should be point.loyalty.balance.

@maurcarvalho
Copy link
Author

Yes. Like informed on the README tutorial, I created a string field inside my migration for transaction_type.

@maurcarvalho
Copy link
Author

Yes I fixed it. Anyway this still not working.

@beerlington
Copy link
Owner

If you remove include ClassyEnum::ActiveRecord from the model, does that fix it? The README is currently for master which has undergone a few changes.

@beerlington
Copy link
Owner

@mauriciojr did that work for you?

@beerlington
Copy link
Owner

Closing this issue, feel free to reach out if you're still having problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants