Sha256: 31bced9b8c6d8f55b7a8ed0a7db705a10b48646b203bff6e6ae04a39d038e71e

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 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 :<%= singular_table_name %>

  def <%= singular_table_name %>
    @<%= singular_table_name %>
  end

  def notice_text
    notice
  end

  def <%= index_helper %>_link
    link_to 'Back', <%= index_helper %>_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/show_presenter.rb.erb
curly-templates-3.3.0 lib/generators/curly/scaffold/templates/show_presenter.rb.erb
curly-templates-3.2.0 lib/generators/curly/scaffold/templates/show_presenter.rb.erb
curly-templates-3.1.0 lib/generators/curly/scaffold/templates/show_presenter.rb.erb
curly-templates-3.0.0 lib/generators/curly/scaffold/templates/show_presenter.rb.erb
curly-templates-2.6.5 lib/generators/curly/scaffold/templates/show_presenter.rb.erb
curly-templates-2.6.4 lib/generators/curly/scaffold/templates/show_presenter.rb.erb
curly-templates-2.6.3 lib/generators/curly/scaffold/templates/show_presenter.rb.erb