Module: Controllers::Showable
- Extended by:
- ActiveSupport::Concern
- Included in:
- ActivityTypesController, AssignmentQueuesController, BankAccountsController, CampaignsController, CatalogsController, CommunicationsController, ContactPointsController, DoNotCallsController, EmployeeGoalsController, EmployeeReviewsController, ItemLedgerEntriesController, LedgerClosingPeriodsController, LedgerTransactionsController, OutgoingPaymentsController, PackagingsController, ShipmentReceiptsController, ShipmentsController, SpiffsController, StoresController, SupplierItemsController, TopicCategoriesController, TopicExamsController, TopicsController, VideosController, WarehousePackagesController
- Defined in:
- app/concerns/controllers/showable.rb
Overview
ActiveSupport::Concern mixin: showable.
Instance Method Summary collapse
-
#perform_show(record_class, _options = {}) ⇒ void
Loads the record for the given model class (reusing an already-set instance variable when present) and responds in HTML, XML, or JSON.
-
#show ⇒ void
Renders the record for the controller's corresponding model class.
Instance Method Details
#perform_show(record_class, _options = {}) ⇒ void
This method returns an undefined value.
Loads the record for the given model class (reusing an already-set
instance variable when present) and responds in HTML, XML, or JSON.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/concerns/controllers/showable.rb', line 19 def perform_show(record_class, = {}) record_instance_name = "@#{record_class.name.tableize.singularize}" record = instance_variable_get(record_instance_name) || record_class.find(params[:id]) # Future, not sure all models have ability defined yet. # authorize! :read, record instance_variable_set(record_instance_name, record) # Redirection will be either succes/error url, or a generalized redir url option, or the index action respond_to do |format| format.html format.xml { head :ok } format.json { head :no_content } end end |
#show ⇒ void
This method returns an undefined value.
Renders the record for the controller's corresponding model class.
10 11 12 |
# File 'app/concerns/controllers/showable.rb', line 10 def show perform_show controller_name.classify.constantize end |