Skip to content

Instantly share code, notes, and snippets.

@parndt
Created June 9, 2010 21:38
Show Gist options
  • Save parndt/432209 to your computer and use it in GitHub Desktop.
Save parndt/432209 to your computer and use it in GitHub Desktop.
def self.find_or_set(name, the_value, options={})
if self.column_names.include?('scoping')
options = {:scoping => nil}.merge(options)
find_or_create_by_name_and_scoping(:name => name.to_s, :value => the_value, :scoping => options[:scoping]).value
else
find_or_create_by_name(:name => name.to_s, :value => the_value).value
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment