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

support for enum #191

Closed
openxyz opened this issue Sep 20, 2016 · 0 comments
Closed

support for enum #191

openxyz opened this issue Sep 20, 2016 · 0 comments

Comments

@openxyz
Copy link

openxyz commented Sep 20, 2016

I store workflow_state as integer in db using enumerize gem ,like {draft:1, submtted:2,passed:3}
but can`t work with error message :

> o.current_state 
undefined method 'to_sym' for 8:Fixnum

it seems the current_state method use value of before_typecast

so i override the load_workflow_state in my model:

def load_workflow_state
   send(self.class.workflow_column).to_sym
end 

def persiste_workflow_state value
    update_columns self.class.workflow_column => self.send(self.class.workflow_column workflow_state).find_value(value)
end

it seems work!

@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