Skip to content

Instantly share code, notes, and snippets.

@thanhcuong1990
Last active August 29, 2015 14:04
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 thanhcuong1990/9ced109ca540d526fc26 to your computer and use it in GitHub Desktop.
Save thanhcuong1990/9ced109ca540d526fc26 to your computer and use it in GitHub Desktop.
Fat model & Skinny controller examples
# /app/models/post.rb
class Post< ActiveRecord::Base
def repost_by(repost)
if self.user == retweeter
"Sorry, you can't retpost your own posts"
elsif
self.retposts.where(:user_id => repost.id).present? "You already reposted!"
else
# ...
"Succesfully reposted"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment