sorry for the newbie question: I have an app which has projects with different asset types (docs, videos, etc.) I'd like to add another asset for audio with identical functionality to the video one. Is there a way I can easily duplicate model/controller/view/table changing 'video(s)' to 'audio(s)'?
You can write a Module
using ActiuveSupport::Convern
that contains all the methods you need in the model then you can include
the Module in the models to extend the models with the methods contained in your Module. Like This:
module AwsomeModule
include ActiveSupport::Concern
module ClassMethods
# awesome class methods here
end
module InstanceMethods
# awesome instance methods here
end
end
Then in Model simply include your Module. For the views you can use Partials and give them the object via the object
and as
options like this:
render 'layouts/awesome_partial', :object => @instance_var, :as => :data
Then in the Partial you cann access the object given using the variable data
.