Skip to content

Instantly share code, notes, and snippets.

@rishav
Created August 10, 2010 20:46
Show Gist options
  • Select an option

  • Save rishav/517976 to your computer and use it in GitHub Desktop.

Select an option

Save rishav/517976 to your computer and use it in GitHub Desktop.
# Instance variables in models
# recently i came across code where a friend of mine had written a lot code in models like its below ( without any attr_reader or accessor ) , is this ok or just plain useless,
def coordinates
@coordinates = [latitude, longitude]
end
# should we do something like below make more sense
def coordinates
@coordinates ||= [latitude, longitude]
end
# or just this is fine
def coordinates
[latitude, longitude]
end
# which one of them is better to use in rails, advantages or disadvantages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment