Skip to content

Instantly share code, notes, and snippets.

@skilldrick
Created July 4, 2011 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skilldrick/1063432 to your computer and use it in GitHub Desktop.
Save skilldrick/1063432 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
# ...
def method_missing method, *args
if method.to_s.starts_with? 'find'
reading_lists.find *args
else
super
end
end
end
# Instead of user.reading_list.find params[:reading_list_id]
# Do user.find_reading_list params[:reading_list_id]
# It just needs generalising
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment