Sha256: 4f232e39a59133f830c6f8fe03e3c9394519b89733a083fe23bd2f80f2410896
Contents?: true
Size: 777 Bytes
Versions: 2
Compression:
Stored size: 777 Bytes
Contents
require_dependency 'avo/application_controller' module Avo class RelationsController < ApplicationController before_action :authorize_user def attach resource.send(params[:attachment_name]) << attachment_model render json: { success: true, message: "#{attachment_class} attached.", } end def detach resource.send(params[:attachment_name]).delete attachment_model render json: { success: true, message: "#{attachment_class} attached.", } end private def attachment_class App.get_model_class_by_name params[:attachment_name].pluralize 1 end def attachment_model attachment_class.safe_constantize.find params[:attachment_id] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
avo-0.3.2 | app/controllers/avo/relations_controller.rb |
avo-0.3.1 | app/controllers/avo/relations_controller.rb |