Sha256: 9221b09b381a00d3a6e54722846090e4a4a3a336f014c5022175a73be6b9f53b

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

class Shared::Collection::TablePresenter < Presenter
  def initialize(subject, options = {})
    super(subject, options)
    
    set_default_options(
      {  
        current_parent: parent, show_title: true, append_new_link: true, show_actions: true
      }
    )
  end
  
  def set_options(options)
    @options.merge!(options)
  end
  
  def actions
    return '' unless show_actions
    
    content_tag :td, render('shared/resource/actions', type: type, resource: resource)
  end
  
  def new_link
    return '' unless append_new_link
    
    path = if current_parent
      eval("new_#{root_model_class_name(current_parent).tableize.singularize}_#{type.gsub('.', '_').singularize}_path(current_parent)")
    else
      eval("new_#{type.gsub('.', '_').singularize}_path")
    end
    
    link_to t("#{type}.new.title"), path
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voluntary-0.1.0.rc1 app/presenters/shared/collection/table_presenter.rb