Skip to content

Doesn't work within a Helper #2

@cschiefelbein

Description

@cschiefelbein

This looks great but it relies on the <%= ... %> construction for th and td elements to be displayed.

If you move the example code into a helper, e.g.

def example
    @front_men = [FrontMan.new(1, 'David St. Hubbins'), FrontMan.new(2, 'David Lee Roth')]

    table_for(@front_men) do |t|
      t.head do
        t.r do
          t.h('Id')
          t.h('Name')
        end
      end
      t.body do |front_man|
        t.r do
          t.d(h(front_man.id))
          t.d(h(front_man.name))
        end
      end
    end
end

The output will include the table and tr tags, but it won't have any content. Passing the content in as a block has the same effect.

Also, for some reason, when the helper method example() is invoked from the .html.erb file, the contents of both are duplicated (my h1 followed by my table, followed by my h1 followed by my table). I believe this is caused by table_helper, because when I replace the table_for() call in example() with a regular old content_tag(), the duplication does not occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions