Module: Controllers::Showable

Overview

ActiveSupport::Concern mixin: showable.

Instance Method Summary collapse

Instance Method Details

#perform_show(record_class, _options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/concerns/controllers/showable.rb', line 12

def perform_show(record_class, _options = {})
  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

#showObject



8
9
10
# File 'app/concerns/controllers/showable.rb', line 8

def show
  perform_show controller_name.classify.constantize
end