title: Rails 3: Creating post model with different post types (image, link, text, video). What kind of inheritance should I use?
body: <p>I am putting together an app that allows users to make posts.  Each post will have a type (image, video, link, text) with both similar and unique variables.  I want to submit these through different forms in a "composer" that's available throughout the site.</p>
  
  <p>Here is the post model, Gallery:</p>
  
  <pre><code>class Gallery &lt; ActiveRecord::Base
      attr_accessible :name, :asset
      has_attached_file :asset, :styles =&gt; { :small =&gt; '160x120#', :medium =&gt; "500x", :thumb =&gt; "300x200#" }
      belongs_to :user
      has_many :likes
      validates :user_id, presence: true
      validates :type, presence: true
      validates :name, presence: true, length: { maximum: 140, minimum: 1 }
  end
  </code></pre>
  
  <p>I was thinking of using Single Table Inheritance, like this:</p>
  
  <pre><code>class Image &lt; Gallery
  end
  
  class Link &lt; Gallery
  end
  
  class Video &lt; Gallery
  end
  
  class Text &lt; Gallery
  end
  </code></pre>
  
  <p>But I'm not achieving the result I want.  For one, I'd like to use the methods in my Gallery controller, such as:</p>
  
  <pre><code># galleries_controller.rb
  def like 
      @gallery = Gallery.find(params[:id])
      @like = @gallery.likes.build(:user_id =&gt; current_user.id)
      respond_to do |format|
          if @like.save
          format.html { redirect_to @gallery }
          format.js
      end
  end
  </code></pre>
  
  <p>end</p>
  
  <p>Moreover, I want to create a "publisher" form that contains a form for each post type and lets you create any kind of post.</p>
  
  <p>How would you approach this?  I'm new to Rails and I want to take advantage of all the conveniences it offers.  Much appreciated!</p>