First of all ajax-datatables-rails is just awesome gem :) I implemented it on Rails 5.0.2. it's previous version, but since there is some params deprecation issue I'm trying to upgrade to Rails 5.1.0 and your v-0-4-0 version.
At the moment I'm a bit stuck as I get this error:
Started GET "/en/medias.json?draw=1&columns%5B0%5D%5Bdata%5D=name&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=0&order%5B0%5D%5Bdir%5D=asc&start=0&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1493747406969" for 10.0.2.2 at 2017-05-02 17:49:56 +0000
Processing by Media::MediasController#index as JSON
Parameters: {"draw"=>"1", "columns"=>{"0"=>{"data"=>"name", "name"=>"", "searchable"=>"true", "orderable"=>"true", "search"=>{"value"=>"", "regex"=>"false"}}}, "order"=>{"0"=>{"column"=>"0", "dir"=>"asc"}}, "start"=>"0", "length"=>"10", "search"=>{"value"=>"", "regex"=>"false"}, "_"=>"1493747406969", "locale"=>"en"}
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 2], ["LIMIT", 1]]
(1.7ms) SELECT COUNT(*) FROM "media_medias"
Completed 500 Internal Server Error in 123ms (ActiveRecord: 7.9ms)
NoMethodError (undefined method `map' for #<ActionController::Parameters:0x007f64980d2038>
Did you mean? tap):
In Gemfile I have
gem 'ajax-datatables-rails', github: 'ajahongir/ajax-datatables-rails', branch: 'v-0-4-0'
I have media_datatables.rb which looks like this:
class MediaDatatable < AjaxDatatablesRails::Base
def view_columns
@view_columns ||= {
name: { source: "Media::Medias.name", cond: :like }
}
end
private
def data
records.map do |media|
{
name: media.name
}
end
end
def get_raw_records
Media::Medias.all
end
end
Index action in controller looks like this:
class Media::MediasController < ApplicationController
include Common::CompaniesHelper
before_action :correct_media, only: [:edit, :update]
def index
respond_to do |format|
format.html
format.json do
render json: MediaDatatable.new(view_context)
end
end
end
First of all ajax-datatables-rails is just awesome gem :) I implemented it on Rails 5.0.2. it's previous version, but since there is some params deprecation issue I'm trying to upgrade to Rails 5.1.0 and your v-0-4-0 version.
At the moment I'm a bit stuck as I get this error:
In Gemfile I have
gem 'ajax-datatables-rails', github: 'ajahongir/ajax-datatables-rails', branch: 'v-0-4-0'
I have media_datatables.rb which looks like this:
Index action in controller looks like this:
index.html.erb is simple as this:
and my medias.coffee looks like this:
I can see in my app it shows some elements of DataTables, so jQuery plugin is working. Can you take a look and say what am I missing, please?