Module: Controllers::Showable

Instance Method Summary collapse

Instance Method Details

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



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

def perform_show(record_class, _options = {})
  error_msg = []
  record_identifier = "#{record_class.name.titleize} record id #{params[:id]}"
  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



6
7
8
# File 'app/concerns/controllers/showable.rb', line 6

def show
  perform_show controller_name.classify.constantize
end