RailsCasts Pro episodes are now free!

Learn more or hide this

John Lyons's Profile

GitHub User: need2surf

Comments by John Lyons



Sorry I have been away for a few days. I can display the table OK with pagination etc but still have the few issues mentioned above, including that I cannot sort or search the table. I intend to re-visit those problems later.

I have added some code to enable the user to select a row by clicking and render the appropriate view. The controller gets the correct id and the log shows the view as being rendered, but it does not show in the browser. I am working on that at present.



Thanks for the great examples. I have a question. One table I wish to show has 3 links to associated tables, and I want to use those associated fields as args for sorting and searching. I cannot work out the syntax in the Ruby class; if it's possible.

When I look at the log I can see 4 queries for every row, the first for the main table and another 3 for each link. Seems very inefficient.

I have this code in the model:

class Neighbour < ActiveRecord::Base

belongs_to :locality, :class_name => "Locality"
belongs_to :neighbour, :class_name => "Locality"
belongs_to :highway, :class_name => "Highway"

default_scope joins(:locality, highway).order('localities.name')


In straight SQL I would achieve this with one query and let the database optimise the method. How would I do this to supply a view of data to the dataTable?



Partially solved. Have included a specific route. No data in my table - will look further into that.



Getting error in view:Extract from log:
Highway Count at list: 229
Rendered highways/list.html.erb within layouts/application (107.9ms)
Completed 500 Internal Server Error in 164ms

ActionView::Template::Error (undefined method `highways_url' for #<#Class:0x98d7c4c:0x98d66a8>):

6: <%= link_to("Add New Highway", {:action => 'new'}, :class => 'action new') %>

8: ">

jQuery ->
sPaginationType: "full_numbers"
bJQueryUI: true
bProcessing: true
bServerSide: true
sAjaxSource: $('#highways').data('source')

What other information can I supply?