ruby on rails - search columns in ajax_datatable_rails? -


class song < activerecord::base   belongs_to :artist   belongs_to :album end   class album < activerecord::base   has_many :songs end class artist < activerecord::base   has_many :songs end 

and query in datatable class songs_datatable.rb

class songdatatable < ajaxdatatablesrails::base   def get_raw_records     song.joins(:artist, :album).select("songs.id, songs.artist_id, songs.album_id, songs.name song_name, songs.location song_location, artists.name artist_name, albums.name album_name")   end end   

what should name of searchable columns songs.name, artists.name, songs.location, albums.name.

def searchable_columns   @searchable_columns ||= [     'songs.name',     'artists.name',     'songs.location',     'albums.name'   ] end 

note: 1 can use database columns sort or search fields, aliases artist_name not work.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -