Ruby on Rails Gem Tables

Does anyone know some good stones you can use to create tables for Ruby on Rails applications. I am looking for something that was created in sorting, AJAX search, etc.

+3
source share
3 answers

check out a thoughtful sortable_table file: http://github.com/thoughtbot/sortable_table

Pop 'sortable_attributes' in your controller:

class UsersController < Admin::BaseController
  sortable_attributes :name, :email, :age, :group => "groups.name"

  def index
    @users = User.paginate :page => params[:page], :order => sort_order
  end
end

Put some helpers in your opinion:

<h1>Users</h1>
<table>
  <tr>
    <%= sortable_table_header :name => "Name",  :sort => "name" %>
    <%= sortable_table_header :name => "Email", :sort => "email" %>
    <%= sortable_table_header :name => "Age",   :sort => "age" %>
    <%= sortable_table_header :name => "Group", :sort => "group" %>
  </tr>
  <% @users.each do |user| %>
    <tr>
      <td><%= html_escape(user.name) %></td>
      <td><%= html_escape(user.email) %></td>
      <td><%= html_escape(user.age) %></td>
      <td><%= html_escape(user.group.name) %></td>
    </tr>
  <% end %>
</table>

done :)

UPDATE (June 2012): The owner of this gem has marked it as outdated and unsupported.

+3
source
+3

Looks like pearls with active scaffolds: http://activescaffold.com/

0
source

Source: https://habr.com/ru/post/1731827/


All Articles