8000 Merge pull request #3 from JoelQ/generators · FiveBox/ajax-datatables-rails@cea90f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit cea90f1

Browse files
author
Joel Quenneville
committed
Merge pull request jbox-web#3 from JoelQ/generators
Record count changes
2 parents 0588e89 + 2890468 commit cea90f1

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

lib/ajax-datatables-rails.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def as_json(options = {})
1818
{
1919
sEcho: params[:sEcho].to_i,
2020
iTotalRecords: @model_name.count,
21-
iTotalDisplayRecords: get_raw_records.count,
21+
iTotalDisplayRecords: get_raw_record_count,
2222
aaData: data
2323
}
2424
end
@@ -29,6 +29,10 @@ def get_raw_records
2929
raise
3030
end
3131

32+
def get_raw_record_count
33+
raise
34+
end
35+
3236
def fetch_records
3337
search_records(sort_records(paginate_records(get_raw_records)))
3438
end

lib/generators/ajaxdatatable/USAGE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
Description:
2-
The cancan:ability generator creates an Ability class in the models
3-
directory. You can move this file anywhere you want as long as it
4-
is in the load path.
2+
The ajaxdatatable generator creates a *_datatable model in the app/datatables directory. This class inherits from AjaxDatatablesRails

lib/generators/filterdatatable/USAGE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Description:
2+
The ajaxdatatable generator creates a *_filter_datatable model in the app/datatables directory. This class overwrites the query in it's parent class
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class FilterdatatableGenerator < Rails::Generators::Base
2+
source_root File.expand_path('../templates', __FILE__)
3+
argument :model, type: :string
4+
5+
def generate_ajaxdatatable
6+
template 'filter.rb', File.join('app/datatables', "#{model.tableize}_filter_datatable.rb")
7+
end
8+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class <%= model.classify.pluralize %>FilterDatatable < <%= model.classify.pluralize %>Datatable
2+
3+
private
4+
5+
def get_raw_records
6+
# insert query here
7+
end
8+
end

0 commit comments

Comments
 (0)
0