Sha256: b49712c678ab0ff009e92d2a418241058d575679e5f5a57a8fe0ea2fd7fb2e44

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

class <%= plural_table_name.capitalize %>::<%= @view_name.capitalize %>Presenter < Curly::Presenter
  # If you need to assign variables to the presenter, you can use the
  # `presents` method.
  #
  #   presents :foo, :bar
  #
  # Any public method defined in a presenter class will be available
  # to the Curly template as a variable. Consider making these methods
  # idempotent.
  presents :<%= plural_table_name %>

  def <%= plural_table_name %>
    @<%= plural_table_name %>
  end

  def notice_text
    notice
  end

  def create_link
    link_to 'New <%= singular_table_name.titleize %>', new_<%= singular_table_name %>_path
  end

  class <%= singular_table_name.capitalize %>Presenter < Curly::Presenter
    presents :<%= singular_table_name %>

    <% attributes.reject(&:password_digest?).each do |attribute| -%>
      def <%= attribute.name %>
        @<%= singular_table_name %>.<%= attribute.name %>
      end
    <% end -%>

    def show_link
      link_to 'Show', @<%= singular_table_name %>
    end

    def edit_link
      link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
    end

    def destroy_link
      link_to 'Destroy', @<%= singular_table_name %>, method: :delete, data: { confirm: 'Are you sure?' }
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
curly-templates-3.4.0 lib/generators/curly/scaffold/templates/index_presenter.rb.erb
curly-templates-3.3.0 lib/generators/curly/scaffold/templates/index_presenter.rb.erb
curly-templates-3.2.0 lib/generators/curly/scaffold/templates/index_presenter.rb.erb
curly-templates-3.1.0 lib/generators/curly/scaffold/templates/index_presenter.rb.erb
curly-templates-3.0.0 lib/generators/curly/scaffold/templates/index_presenter.rb.erb
curly-templates-2.6.5 lib/generators/curly/scaffold/templates/index_presenter.rb.erb
curly-templates-2.6.4 lib/generators/curly/scaffold/templates/index_presenter.rb.erb
curly-templates-2.6.3 lib/generators/curly/scaffold/templates/index_presenter.rb.erb