Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

John Lyons's Profile

GitHub User: need2surf

Comments by John Lyons

Avatar

Rick,

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.

John

Avatar

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')

end

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?

Thanks

Avatar

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

Thanks

Avatar

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>):
5:

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

8: ">

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

Rails:3.2.1.
What other information can I supply?

Thanks