Sha256: f2b32ab6b00999a4d5f9f1732340672121ec109218cc73a4facc530a3206d4e7
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
## To migrate from `v0.4.x` to `v1.0.0` 1) To mitigate the first change (Datatables no longer inherits from `AjaxDatatablesRails::Base` but from `AjaxDatatablesRails::ActiveRecord`) Create a new `ApplicationDatatable` class and make all your classes inherits from it : ```ruby class ApplicationDatatable < AjaxDatatablesRails::ActiveRecord end class PostDatatable < ApplicationDatatable end ``` **Note :** This is now in the [ProTips™](https://github.com/jbox-web/ajax-datatables-rails#protips) section of the documentation. 2) To mitigate the second change (The `view_context` is no longer injected in Datatables) Update the `ApplicationDatatable` class : ```ruby class ApplicationDatatable < AjaxDatatablesRails::ActiveRecord extend Forwardable attr_reader :view def initialize(params, opts = {}) @view = opts[:view_context] super end end ``` and update your controllers : ```ruby # before respond_to do |format| format.json { render json: UserDatatable.new(view_context) } end # after respond_to do |format| format.json { render json: UserDatatable.new(params, view_context: view_context) } end # if you need to inject some options respond_to do |format| format.json { render json: UserDatatable.new(params, view_context: view_context, my: 'options') } end ``` This way, you can still use `def_delegators` in your datatables [as in the documentation](https://github.com/jbox-web/ajax-datatables-rails#using-view-helpers). Note that the recommanded way is to use [Draper gem](https://github.com/drapergem/draper) to separate filtering logic from view/presentation logic [as in the documentation](https://github.com/jbox-web/ajax-datatables-rails#using-view-decorators).
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ajax-datatables-rails-1.2.0 | doc/migrate.md |
ajax-datatables-rails-1.1.0 | doc/migrate.md |
ajax-datatables-rails-1.0.0 | doc/migrate.md |