Forum: Ruby on Rails New Ajax and Rails tutorial

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
59b51627e2c3c882fa8c21022000fa11?d=identicon&s=25 Julien Barnier (Guest)
on 2006-05-07 01:20
Hi,

I just published the first version of a small tutorial I've written on
Ajax and Rails. It is called "How to paginate, sort and search a table
with Ajax and Rails" (sorry, I didn't manage to find a longer title !)
and is available at :

http://dev.nozav.org/rails_ajax_table.html

There is nothing really new in it, it's rather a compilation and
adaptation of several Rails wiki pages.

As I am neither a Rails expert nor a native english speaker, I would
greatly appreciate any feedback.

Thanks,

Julien
Cfe570353b00ad511dd2f921d1bc02ad?d=identicon&s=25 richard (Guest)
on 2006-05-07 01:41
Julien Barnier wrote:
> Hi,
>
> I just published the first version of a small tutorial I've written on
> Ajax and Rails. It is called "How to paginate, sort and search a table
> with Ajax and Rails" (sorry, I didn't manage to find a longer title !)
> and is available at :
>
> http://dev.nozav.org/rails_ajax_table.html
>
> There is nothing really new in it, it's rather a compilation and
> adaptation of several Rails wiki pages.
>
> As I am neither a Rails expert nor a native english speaker, I would
> greatly appreciate any feedback.
>
> Thanks,
>
> Julien

Thanks Julien,

I just did a quick glance but it looks really promising.  Great
explanations of theory and code.

Keep those tutorials coming!
1b6ed15a6126e1d5ef4d7d15550f30bb?d=identicon&s=25 François Montel (zerohalo)
on 2006-05-07 01:55
(Received via mailing list)
Thanks, Julien. It looks good. More stuff like this is needed. I'll try
it
out in an app I'm working on and see how it goes, and offer any
feedback.

It would be nice to put a link to it on the Rails wiki if you haven't
already. That way people can more easily find it.
9c39060182e52f2749f932ed0f3d9ff7?d=identicon&s=25 Malamute Jute (mutejute)
on 2006-05-07 13:49
i tried this (by cut and paste) and gets this
(http://localhost:3000/item/list):

 ActiveRecord::StatementInvalid in Item#list

Mysql::Error: Unknown column 'conditions' in 'where clause': SELECT
COUNT(*) FROM items WHERE (conditions)

RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace

./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:88:in
`log'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:180:in
`execute'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:322:in
`select'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:175:in
`select_one'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:16:in
`select_value'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:518:in
`count_by_sql'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:511:in
`count'
./script/../config/../app/controllers/item_controller.rb:18:in `list'

./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:88:in
`log'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:180:in
`execute'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:322:in
`select'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:175:in
`select_one'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:16:in
`select_value'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:518:in
`count_by_sql'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:511:in
`count'
./script/../config/../vendor/rails/actionpack/lib/action_controller/base.rb:853:in
`perform_action_without_filters'
./script/../config/../vendor/rails/actionpack/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark'
./script/../config/../vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
./script/../config/../vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
./script/../config/../vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in
`perform_action'
./script/../config/../vendor/rails/actionpack/lib/action_controller/base.rb:369:in
`process_without_session_management_support'
./script/../config/../vendor/rails/actionpack/lib/action_controller/session_management.rb:116:in
`process'
./script/../config/../vendor/rails/railties/lib/dispatcher.rb:38:in
`dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:117:in
`handle_dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:83:in
`service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:69:in
`dispatch'
./script/../config/../vendor/rails/railties/lib/commands/servers/webrick.rb:59
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:214:in
`require'
./script/../config/../vendor/rails/railties/lib/commands/server.rb:28
./script/server:3

./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:88:in
`log'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:180:in
`execute'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:322:in
`select'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:175:in
`select_one'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:16:in
`select_value'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:518:in
`count_by_sql'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:511:in
`count'
./script/../config/../app/controllers/item_controller.rb:18:in `list'
./script/../config/../vendor/rails/actionpack/lib/action_controller/base.rb:853:in
`perform_action_without_filters'
./script/../config/../vendor/rails/actionpack/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark'
./script/../config/../vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
./script/../config/../vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
./script/../config/../vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in
`perform_action'
./script/../config/../vendor/rails/actionpack/lib/action_controller/base.rb:369:in
`process_without_session_management_support'
./script/../config/../vendor/rails/actionpack/lib/action_controller/session_management.rb:116:in
`process'
./script/../config/../vendor/rails/railties/lib/dispatcher.rb:38:in
`dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:117:in
`handle_dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:83:in
`service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:69:in
`dispatch'
./script/../config/../vendor/rails/railties/lib/commands/servers/webrick.rb:59
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:214:in
`require'
./script/../config/../vendor/rails/railties/lib/commands/server.rb:28
./script/server:3

Request

Parameters: None

Show session dump

---
flash: !map:ActionController::Flash::FlashHash {}


Response
Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
59b51627e2c3c882fa8c21022000fa11?d=identicon&s=25 Julien Barnier (Guest)
on 2006-05-07 19:49
Hi,

> Mysql::Error: Unknown column 'conditions' in 'where clause': SELECT
> COUNT(*) FROM items WHERE (conditions)

That is a bit strange. I just tried to reproduce it here by using Mysql
as database, but it works for me.

The error is as the code didn't interpolate the "conditions" variables
in the item controller. Are you sure you have the following syntax in
item_controller.rb ?

conditions = "name LIKE '%#{@params[:query]}%'" unless
@params[:query].nil?
@total = Item.count(:conditions => conditions)
@items_pages, @items = paginate :items, :order => sort, :conditions =>
conditions, :per_page => items_per_page

Or maybe you could try with sqlite, but I don't think the problem comes
from the database used...

Thanks for the feedback,

Julien
9c39060182e52f2749f932ed0f3d9ff7?d=identicon&s=25 malamute jute (Guest)
on 2006-05-08 00:56
Julien Barnier wrote:

>
> The error is as the code didn't interpolate the "conditions" variables
> in the item controller. Are you sure you have the following syntax in
> item_controller.rb ?
>
> conditions = "name LIKE '%#{@params[:query]}%'" unless
> @params[:query].nil?
> @total = Item.count(:conditions => conditions)
> @items_pages, @items = paginate :items, :order => sort, :conditions =>
> conditions, :per_page => items_per_page
>

yes. i have exactly those code in item_controller.rb . im using rails
1.0, ruby 1.8.4, mysql 5.0.x, ubuntu dapper beta.
59b51627e2c3c882fa8c21022000fa11?d=identicon&s=25 Julien Barnier (Guest)
on 2006-05-08 17:09
Hi,

> yes. i have exactly those code in item_controller.rb . im using rails
> 1.0, ruby 1.8.4, mysql 5.0.x, ubuntu dapper beta.

Hmmm... Maybe you could try with a query parameter in your request, for
example :

http://localhost:3000/itm/list/?query=a

Or maybe you could replace he 'conditions' variable with '@conditions' ?
9c39060182e52f2749f932ed0f3d9ff7?d=identicon&s=25 malamute jute (Guest)
on 2006-05-08 19:00
Julien Barnier wrote:
> Hi,

>
> http://localhost:3000/itm/list/?query=a

if i try that, here's the error:

Mysql::Error: Unknown column 'conditionsname' in 'where clause': SELECT
COUNT(*) FROM items WHERE (conditionsname LIKE '%a%')

the word 'conditions' seems to be stucked.

>
> Or maybe you could replace he 'conditions' variable with '@conditions' ?

if i do this, i get the same error as before:

Mysql::Error: Unknown column 'conditions' in 'where clause': SELECT
COUNT(*) FROM items WHERE (conditions)
This topic is locked and can not be replied to.