Skip to content

Instantly share code, notes, and snippets.

@orbanbotond
Created July 23, 2013 13:51
Show Gist options
  • Save orbanbotond/6062484 to your computer and use it in GitHub Desktop.
Save orbanbotond/6062484 to your computer and use it in GitHub Desktop.
scopes for state_machine states
def Price.generate_scopes_for_state_machines
state_machines.each_pair do |machine_name, that_machine|
that_machine.states.map do |state|
# puts "will create these scopes: #{machine_name}_#{state.name} state: #{state.value} "
# puts "will create these scopes: #{machine_name}_#{state.name} state: #{state.name.to_s} "
# Price.scope "#{machine_name}_#{state.name}", :conditions => { machine_name => state.name.to_s }
Price.scope "#{machine_name}_#{state.name}", :conditions => { machine_name => state.value }
end
end
end
Price.generate_scopes_for_state_machines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment