simple_grid 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +45 -42
  2. data/lib/simple_grid/version.rb +1 -1
  3. metadata +1 -1
data/README.md CHANGED
@@ -5,28 +5,27 @@ SimpleGrid is the most easy way to transform your CRUD in a powerful jQuery Data
5
5
  ## Requisites
6
6
 
7
7
  * Rails 3.1 (asset pipeline) - You can run it in minor versions but you need to add the assets manually (not tested yet).
8
- * ActiveRecord
9
8
 
10
9
  ## Installation
11
10
 
12
11
  Install the gem:
13
12
 
14
- $ gem install simple_grid
13
+ $ gem install simple_grid
15
14
 
16
15
  Add this line to your Rails application Gemfile:
17
16
 
18
- gem 'simple_grid'
17
+ gem 'simple_grid'
19
18
 
20
19
  Execute:
21
20
 
22
- $ bundle install
23
- $ rails generate simple_grid:install
21
+ $ bundle install
22
+ $ rails generate simple_grid:install
24
23
 
25
24
  Include the SimpleGrid helper in your ApplicationHelper:
26
25
 
27
- module ApplicationHelper
28
- include SimpleGrid::Helpers
29
- end
26
+ module ApplicationHelper
27
+ include SimpleGrid::Helpers
28
+ end
30
29
 
31
30
  Load the assets in your application.
32
31
 
@@ -34,44 +33,48 @@ Load the assets in your application.
34
33
 
35
34
  Is very easy to use the SimpleGrid gem, suppose that we have the tables Books and Authors. Each book has an author and an author has many books.
36
35
 
37
- To use the gem in our book index view we need to call the method simple_grid. Like bellow:
36
+ To use the gem in our book index view we need to call the method simple_grid. Like below:
38
37
 
39
- <%= simple_grid(@books) %>
40
- # The first parameter is our records based on ActiveRecord.
41
- # In this example it will display a grid with all table columns and the actions show, edit and destroy.
38
+ <%= simple_grid(@books) %>
39
+ # The first parameter is our records based on ActiveRecord.
40
+ # In this example it will display a grid with all table columns and the actions show, edit and destroy.
42
41
 
43
42
  The second parameter can be an options hash, see the examples below:
44
43
 
45
- <%= simple_grid(@books, :exclude_columns => ["id","description","created_at","updated_at"]) %>
46
- # In this example it will not display the columns present in :exclude_columns array
47
-
48
- <%= simple_grid(@books, :exclude_columns => ["id","description"],
49
- :extra_columns => {
50
- :author_name => { :label => "Author", :relationship => "author.name" }
51
- }) %>
52
- # In this example it will not display the columns "id" and "description" but it will display an extra column with the author name based in our relationship.
53
- # The :label key is the column title and the :relationship key is our models relationship.
54
-
55
- <%= simple_grid(@books, :exclude_columns => ["id","description"],
56
- :extra_columns => {
57
- :author_name => { :label => "Author", :relationship => "author.name" },
58
- :other_column => { :label => "New Column", :content => "<strong>Content</strong>" }
59
- }) %>
60
- # In this example it will add a new column with label "New column" and the content as html.
61
-
62
- <%= simple_grid(@books, :exclude_columns => ["id","description"],
63
- :extra_columns => {
64
- :author_name => { :label => "Author", :relationship => "author.name" }
65
- },
66
- :actions => {
67
- :show => { :label => "View", :html => { :id => "show_info" } },
68
- :edit => { :route => "my_route" },
69
- :destroy => { :display => false }
70
- }) %>
71
- # In this example it will display the actions based in the hash options.
72
- # The action show will be displayed with label "View" and the id "show_info" in the html element.
73
- # The action edit will use the route "my_route" (it will interprete as "my_route(record)").
74
- # The action destroy will not be displayed.
44
+ In this example it will not display the columns present in :exclude_columns array
45
+
46
+ <%= simple_grid(@books, :exclude_columns => ["id","description","created_at","updated_at"]) %>
47
+
48
+ In this example it will not display the columns "id" and "description" but it will display an extra column with the author name based in our relationship.
49
+
50
+ <%= simple_grid(@books, :exclude_columns => ["id","description"],
51
+ :extra_columns => {
52
+ :author_name => { :label => "Author", :relationship => "author.name" }
53
+ }) %>
54
+ # The :label key is the column title and the :relationship key is our models relationship.
55
+
56
+ In this example it will add a new column with label "New column" and the content as html.
57
+
58
+ <%= simple_grid(@books, :exclude_columns => ["id","description"],
59
+ :extra_columns => {
60
+ :author_name => { :label => "Author", :relationship => "author.name" },
61
+ :other_column => { :label => "New Column", :content => "<strong>Content</strong>" }
62
+ }) %>
63
+
64
+ In this example it will display the actions based in the hash options.
65
+
66
+ <%= simple_grid(@books, :exclude_columns => ["id","description"],
67
+ :extra_columns => {
68
+ :author_name => { :label => "Author", :relationship => "author.name" }
69
+ },
70
+ :actions => {
71
+ :show => { :label => "View", :html => { :id => "show_info" } },
72
+ :edit => { :route => "my_route" },
73
+ :destroy => { :display => false }
74
+ }) %>
75
+ # The action show will be displayed with label "View" and the id "show_info" in the html element.
76
+ # The action edit will use the route "my_route" (it will interprete as "my_route(record)").
77
+ # The action destroy will not be displayed.
75
78
 
76
79
  ## TODO
77
80
 
@@ -1,3 +1,3 @@
1
1
  module SimpleGrid
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: