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

default_scope breaks initial state #121

Closed
paulslaby opened this issue Aug 28, 2014 · 1 comment
Closed

default_scope breaks initial state #121

paulslaby opened this issue Aug 28, 2014 · 1 comment

Comments

@paulslaby
Copy link

Not sure, if it is problem of this gem, but people might be trying to find solution here.

This is my code:

class Recipe < ActiveRecord::Base
default_scope {where(:state => :approved)}

include Workflow
workflow_column :state
workflow do
state :new do
event :approve, transitions_to: :approved
end
state :approved
end
end

when I run rails c:
Recipe.new.state
=> :approved

when commenting out defaul_scope, it is ok.

@paulslaby
Copy link
Author

I use this workaround:

def initialize(attrs={}, *args)
super({:state => :new}.merge!(attrs), args)
end

@geekq geekq closed this as completed May 29, 2022
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