Created
August 7, 2012 15:01
-
-
Save Iknewthisguy/3286103 to your computer and use it in GitHub Desktop.
Module Refactoring - Sample Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < < ActiveRecord::Base | |
def self.find_by_vanity(vname) | |
#m = User.find vname | |
v = Vanity.find_by_name(vname) | |
m = v.try(:vanity) | |
#if we couldnt find by Vanity, lets try finding by regular id: | |
unless v and m | |
begin | |
m = User.find!(vname) | |
rescue NativeException | |
raise Neo4j::Rails::RecordNotFoundError | |
end | |
end | |
return m | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment