You'll hear it lots, fat models/skinny controllers but I was working on a project recently where my controller code was putting on a bit of weight!
The requirement was that when a post was saved with a url, a gem I had installed called LinkThumbnailer would visit that url to find the first image on the page and return the image url.
I had a case in my postit application where I needed to add voting for both comments and posts. This required some code in my models for Post and Comment to count the votes:
has_many :votes, as: :voteable
def total_votes
up_votes - down_votes
end
def up_votes
self.votes.where(vote: true).size
end
def down_votes
self.votes.where(vote: false).size
end
This is just a quick reminder on the make up of a URL and basic details of a HTTP request/response cycle.