Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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