I am building an application that allows users to create posts. Each message will have a type (image, video, link, text) with the same and unique variables. I want to present them through various forms in the "composer", available on the entire site.
Here is the publication model, Gallery:
class Gallery < ActiveRecord::Base attr_accessible :name, :asset has_attached_file :asset, :styles => { :small => '160x120#', :medium => "500x", :thumb => "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
I was thinking about using Single Table Inheritance, for example:
class Image < Gallery end class Link < Gallery end class Video < Gallery end class Text < Gallery end
But I did not achieve the result I want. First, I would like to use methods in my Gallery controller, for example:
end
In addition, I want to create a βpublisherβ form, which contains a form for each type of message and allows you to create any message.
How would you approach this? I am new to Rails and I want to take advantage of all the amenities that it offers. Really appreciate!