module ActiveScaffold::Actions::Show

Public Class Methods

included(base) click to toggle source
# File lib/active_scaffold/actions/show.rb, line 3
def self.included(base)
  base.before_filter :show_authorized_filter, :only => :show
end

Public Instance Methods

show() click to toggle source
# File lib/active_scaffold/actions/show.rb, line 7
def show
  # rest destroy falls back to rest show in case of disabled javascript
  # just render action_confirmation message for destroy
  if params.delete :destroy_action
    @record = find_if_allowed(params[:id], :read) if params[:id]
    action_confirmation_respond_to_html(:destroy)
  else
    do_show
    respond_to_action(:show)
  end
end

Protected Instance Methods

do_show() click to toggle source

A simple method to retrieve and prepare a record for showing. May be overridden to customize show routine

# File lib/active_scaffold/actions/show.rb, line 43
def do_show
  set_includes_for_columns(:show) if active_scaffold_config.actions.include? :list
  klass = beginning_of_chain.preload(active_scaffold_preload)
  @record = find_if_allowed(params[:id], :read, klass)
end
show_authorized?(record = nil) click to toggle source

The default security delegates to ActiveRecordPermissions. You may override the method to customize.

# File lib/active_scaffold/actions/show.rb, line 51
def show_authorized?(record = nil)
  (record || self).send(:authorized_for?, :crud_type => :read)
end
show_columns_names() click to toggle source
# File lib/active_scaffold/actions/show.rb, line 37
def show_columns_names
  active_scaffold_config.show.columns.names
end
show_ignore?(record = nil) click to toggle source
# File lib/active_scaffold/actions/show.rb, line 55
def show_ignore?(record = nil)
  !send(:authorized_for?, :crud_type => :read)
end
show_respond_to_html() click to toggle source
# File lib/active_scaffold/actions/show.rb, line 33
def show_respond_to_html
  render :action => 'show'
end
show_respond_to_js() click to toggle source
# File lib/active_scaffold/actions/show.rb, line 29
def show_respond_to_js
  render :partial => 'show'
end
show_respond_to_json() click to toggle source
# File lib/active_scaffold/actions/show.rb, line 21
def show_respond_to_json
  render :json => response_object, :only => show_columns_names + [active_scaffold_config.model.primary_key], :include => association_columns(show_columns_names), :methods => virtual_columns(show_columns_names), :status => response_status
end
show_respond_to_xml() click to toggle source
# File lib/active_scaffold/actions/show.rb, line 25
def show_respond_to_xml
  render :xml => response_object, :only => show_columns_names + [active_scaffold_config.model.primary_key], :include => association_columns(show_columns_names), :methods => virtual_columns(show_columns_names), :status => response_status
end

Private Instance Methods

show_authorized_filter() click to toggle source
# File lib/active_scaffold/actions/show.rb, line 61
def show_authorized_filter
  link = active_scaffold_config.show.link || active_scaffold_config.show.class.link
  raise ActiveScaffold::ActionNotAllowed unless send(link.security_method)
end
show_formats() click to toggle source
# File lib/active_scaffold/actions/show.rb, line 66
def show_formats
  (default_formats + active_scaffold_config.formats + active_scaffold_config.show.formats).uniq
end