effective_datatables 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cac210863d261aefc49a0143d72be5111108cb88
4
- data.tar.gz: 63281eaaec4afe44f78a33b46ed532231f6d168b
3
+ metadata.gz: a42cb00a5e666c63e32719f2a374815565081d6f
4
+ data.tar.gz: 7240887e0bf62acfbf1b8c9ea84384e8cdb62dc1
5
5
  SHA512:
6
- metadata.gz: 09cc07fd28c9ff8669fa00bdc18e0445f64d4f4213702c3063e7dffa62fa32bc326b030ca05d1b2377c1270ba8ca6217373dc18147a5d0dea6b1697d32191ffb
7
- data.tar.gz: 1b4e19fdcd722c4f5577aefa36662e91b59b246571f0a45d67602c413f77b8b85c69722e3425674c06d469478e6f9d17298d3f7e52ec57cf359833e55e17a4d2
6
+ metadata.gz: d21b2e00f36bb5ba1a8c10261b546898ac87e6e22aa180ac217d79fb3d6d147ac8982b31a62a3164a181bee2ee117ad83493fb069346124f5ba001c539e0bf1a
7
+ data.tar.gz: 660ba3f0de0836cdb7099176885930e1eab311fed4d57f7191de2251ae1f2b8c60d70c910fdb1295724145e63ba29836adfc4b9b57ed948a9e5dc4142e78b9aa
data/README.md CHANGED
@@ -457,6 +457,53 @@ table_column :user_id, :if => Proc.new { attributes[:user_id].blank? } do |post|
457
457
  end
458
458
  ```
459
459
 
460
+ ### Helper methods
461
+
462
+ Any non-private methods defined in the datatable model will be available to your table_columns and evaluated in the view_context.
463
+
464
+ ```ruby
465
+ module Effective
466
+ module Datatables
467
+ class Posts < Effective::Datatable
468
+ table_column :title do |post|
469
+ format_post_title(post)
470
+ end
471
+
472
+ def collection
473
+ Post.all
474
+ end
475
+
476
+ def format_post_title(post)
477
+ if post.title.start_with?('important')
478
+ link_to(post.title.upcase, post_path(post))
479
+ else
480
+ link_to(post.title, post_path(post))
481
+ end
482
+ end
483
+
484
+ end
485
+ end
486
+ end
487
+ ```
488
+
489
+ You can also get the same functionality by including a regular Rails helper within the datatable model.
490
+
491
+ ```ruby
492
+ module PostHelper
493
+ end
494
+ ```
495
+
496
+ ```ruby
497
+ module Effective
498
+ module Datatables
499
+ class Posts < Effective::Datatable
500
+ include PostsHelper
501
+
502
+ end
503
+ end
504
+ end
505
+ ```
506
+
460
507
  ## Array Backed collection
461
508
 
462
509
  Don't want to use ActiveRecord? Not a problem.
@@ -71,7 +71,7 @@ module EffectiveDatatablesHelper
71
71
  end
72
72
 
73
73
  def datatables_admin_path?
74
- (attributes[:admin_path] || request.referer.downcase.start_with?('/admin')) rescue false
74
+ (attributes[:admin_path] || request.referer.chomp('/').end_with?('/admin')) rescue false
75
75
  end
76
76
 
77
77
  # TODO: Improve on this
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails