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

get value for state name? #27

Closed
arches opened this issue Jun 17, 2015 · 4 comments
Closed

get value for state name? #27

arches opened this issue Jun 17, 2015 · 4 comments

Comments

@arches
Copy link

arches commented Jun 17, 2015

I have a bunch of states defined with custom values. How can I retrieve the value for a given state? Thanks!

@rosskevin
Copy link
Member

@arches can you give me a better description? Also, unless this is related to the activerecord integration, this might be better asked in the parent project, https://github.com/state-machines/state_machines/issues

In the parent project readme, it shows (and I use it this way):

vehicle.state                   # => "parked"
vehicle.state_name              # => :parked

@arches
Copy link
Author

arches commented Jun 19, 2015

My setup:

class Vehicle
  state_machine :state do
    state :parked, value: 0
  end
end

My goal is to turn :parked back into 0, for example:

Vehicle.state_value(:parked) # => 0

(Sorry to ask in the wrong place, I got here from pluginaweek/state_machine#343)

@rosskevin
Copy link
Member

I'm not sure, but I'm curious to know as well. @renchap in #13 might be interested too. I'd definitely close this one and ask in the parent, might get more help. Also, thanks for the note about where you came from, I asked @Styxx to make an update to the link.

@arches
Copy link
Author

arches commented Jun 19, 2015

ok, thanks @rosskevin! moved to state-machines/state_machines#22

@arches arches closed this as completed Jun 19, 2015
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