I would like some advice which relates to the "fat model skinny controller" concept in Rails.
See my show action in the Micropost controller
def show @micropost = Micropost.find(params[:id]) @tags = @micropost.tag_counts_on(:tags) @responses = @micropost.responses @response = current_user.responses.build if member_signed_in? impressionist(@micropost) related_posts = Micropost.tagged_with(@micropost.tag_list, :on => :tags, :any => true).take(5) @cleaned_related_posts = Micropost.assemble_related_posts(related_posts, @micropost) end
This action does a number of things. 1. It shows a micropost 2. It gets all the tags (acts as taggable) from the micropost (to display them) 3. It builds the response - response form is on the same page 4. It impressions the micropost (impressionist gem) 5. Lastly, it builds a list of related microposts. I tried to clean this up by using a class method in my micropost class as follows
def self.assemble_related_posts(related_posts = , micropost) @cleaned_related_posts =  related_posts.each do |post| unless post == micropost @cleaned_related_posts.push(post) end end @cleaned_related_posts end
The related posts variable above INCLUDES the micropost being shown - no point in that, so I wrote a class method to remove it.
This show action is pretty fat, and my RubyMine keeps showing me a warning that the controller should call only one method.
I want to improve my skills (I am fairly new to Rails). Is there a "Rails way" to shift all this logic into the model.....should it be done? Are some controllers simply going to a bit on the fat side?