Hmmmm<br>
<br>
My first thought was to look at the SQL statement that is being passed to MySQL&nbsp; and the error returned.&nbsp; <br>
<br>
'ActiveRecord::StatementInvalid (Mysql::Error: <span style="background-color: rgb(255, 255, 102);">Unknown column 'tag_id'</span><br>
in 'where clause': SELECT id FROM customers WHERE (<span style="background-color: rgb(255, 255, 102);">tag_id = 3</span>) '<br>
<br>
This is why I was asking about the column in your customers table.&nbsp; I
am fairly new to the RoR architecture and development but I have had
many years with MySQL and this seems to be an easy debug if looked into in a simplistic way.&nbsp; <br><br>In the end this is not working because of a miss reference to a column:<br><br> &nbsp; def list<br> &nbsp; &nbsp; @customer_pages, @customers = paginate :customers, {:per_page =&gt;
<br>10, :include =&gt; 'tags', <span style="background-color: rgb(255, 255, 102);">:conditions=&gt;'tag_id = 3'</span>}<br> &nbsp; end<br><br>Hope this helps. :-)<br><br>Jason<br><br><div><span class="gmail_quote">On 3/31/06, 
<b class="gmail_sendername">Julian Leviston</b> &lt;<a href="mailto:julian@coretech.net.au">julian@coretech.net.au</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Jason,<br><br>Did you notice that there is an :include =&gt; 'tags' section in the<br>hash as passed in to the pagination request?<br><br>Oh.. it should be <a href="http://tags.id">tags.id</a> = 2 , shouldn't it?<br><br>ARGH... &lt;grinz&gt;
<br><br>Julian.<br><br>On 01/04/2006, at 12:58 AM, Jason West wrote:<br><br>&gt; I guess my questoin to you would be is there such a column called<br>&gt; 'tag_id' in you customers table?&nbsp;&nbsp;If not then this is where the<br>
&gt; issue lies as the mysql errors states that it cannot find the field<br>&gt; in when the query is ran.<br>&gt;<br>&gt; Thanks<br>&gt;<br>&gt; Jason L. West, Sr.<br>&gt;<br>&gt; On 3/31/06, Julian Leviston &lt;<a href="mailto:julian@coretech.net.au">
julian@coretech.net.au</a>&gt; wrote: Hello<br>&gt; list,<br>&gt;<br>&gt; I've had this problem for two days now. Perhaps someone here would<br>&gt; care to comment on it. I'd be REALLY appreciative if that'd be the<br>&gt; case.
<br>&gt;<br>&gt; Basically, it's outlined at this paste: <a href="http://rafb.net/paste/results/">http://rafb.net/paste/results/</a><br>&gt; kXQSHZ83.html<br>&gt;<br>&gt; But I'll paste it here, too.<br>&gt;<br>&gt; The main problem is in the customers/list action. The problem is with
<br>&gt; this line:<br>&gt; @customer_pages, @customers = paginate :customers, {:per_page =&gt;<br>&gt; 10, :include =&gt; 'tags', :conditions=&gt;'tag_id = 3'}<br>&gt;<br>&gt; It's generating the exception below. Any help would be INCREDIBLY
<br>&gt; appreciated. Please b/cc me in on any replies.<br>&gt;<br>&gt; Kind Regards,<br>&gt; Julian.<br>&gt;<br>&gt;<br>&gt;<br>&gt; #The problem is in the customer-list action.<br>&gt; #... it yields the error below the source code that follows:
<br>&gt; # source code follows:<br>&gt;<br>&gt; class CreateCustomers &lt; ActiveRecord::Migration<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def self.up<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;create_table :customers do |t|<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# t.column :name, :string<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def self.down<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;drop_table :customers<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt; end<br>&gt;<br>&gt; class CreateTags &lt; ActiveRecord::Migration<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def self.up<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;create_table :tags do |t|
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# t.column :name, :string<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def self.down<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;drop_table :tags<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt; end<br>&gt;<br>&gt;<br>&gt; class Customer &lt; ActiveRecord::Base
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;has_and_belongs_to_many :tags<br>&gt; end<br>&gt;<br>&gt; class Tag &lt; ActiveRecord::Base<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;has_and_belongs_to_many :customers<br>&gt; end<br>&gt;<br>&gt;<br>&gt; class CustomersController &lt; ApplicationController
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def index<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;render :action =&gt; 'list'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;# GETs should be safe (see <a href="http://www.w3.org/2001/tag/doc/">http://www.w3.org/2001/tag/doc/</a><br>
&gt; whenToUseGet.html)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;verify :method =&gt; :post, :only =&gt; [ :destroy, :create, :update ],<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :redirect_to =&gt; { :action =&gt; :list }<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def list<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@customer_pages, @customers = paginate :customers, {:per_page =&gt;
<br>&gt; 10, :include =&gt; 'tags', :conditions=&gt;'tag_id = 3'}<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def show<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@customer = Customer.find(params[:id])<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def new<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@customer = 
Customer.new<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def create<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@customer = Customer.new(params[:customer])<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if @ customer.save<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flash[:notice] = 'Customer was successfully created.'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect_to :action =&gt; 'list'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;render :action =&gt; 'new'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def edit<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@customer = Customer.find(params[:id])<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def update<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@customer = Customer.find(params[:id])<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if @customer.update_attributes(params[:customer])<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flash[:notice] = 'Customer was successfully updated.'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect_to :action =&gt; 'show', :id =&gt; @customer
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;render :action =&gt; 'edit'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;def destroy<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Customer.find(params[:id]).destroy<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect_to :action =&gt; 'list'<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt; end<br>&gt;<br>&gt;<br>&gt; # exception that is generated when trying to access list page:<br>&gt;<br>&gt; Processing CustomersController#list (for <a href="http://127.0.0.1">127.0.0.1</a> at 2006-04-01
<br>&gt; 00:40:10) [GET]<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Session ID: ee0f5f8afb0b2740be5f9463b8962e0b<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Parameters: {&quot;action&quot;=&gt;&quot;list&quot;, &quot;controller&quot;=&gt;&quot;customers&quot;}<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Customer Count (
0.000700)&nbsp;&nbsp; SELECT COUNT(DISTINCT <a href="http://customers.id">customers.id</a>)<br>&gt; FROM customers LEFT OUTER JOIN customers_tags ON<br>&gt; customers_tags.customer_id = <a href="http://customers.id">customers.id</a>
 LEFT OUTER JOIN tags ON<br>&gt; <a href="http://tags.id">tags.id</a> = customers_tags.tag_id WHERE (tag_id = 3)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Customer Columns (0.000248)&nbsp;&nbsp; SHOW FIELDS FROM customers<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Tag Columns (0.000186)&nbsp;&nbsp; SHOW FIELDS FROM tags
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Customer Load IDs For Limited Eager Loading (0.000000)<br>&gt; Mysql::Error: Unknown column 'tag_id' in 'where clause': SELECT id<br>&gt; FROM customers WHERE (tag_id = 3) LIMIT 0, 10<br>&gt;<br>&gt;<br>&gt; ActiveRecord::StatementInvalid (Mysql::Error: Unknown column 'tag_id'
<br>&gt; in 'where clause': SELECT id FROM customers WHERE (tag_id = 3)&nbsp;&nbsp;LIMIT<br>&gt; 0, 10):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord- 1.14.0/lib/<br>&gt; active_record/connection_adapters/abstract_adapter.rb:120:in `log'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/<br>&gt; active_record/connection_adapters/mysql_adapter.rb:185:in `execute'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/<br>
&gt; active_record/connection_adapters/mysql_adapter.rb:337:in `select'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/<br>&gt; active_record/connection_adapters/mysql_adapter.rb:176:in `select_all'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/<br>&gt; active_record/connection_adapters/abstract/database_statements.rb:<br>&gt; 23:in `select_values'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-
1.14.0 /lib/<br>&gt; active_record/associations.rb:1147:in `select_limited_ids_list'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/<br>&gt; active_record/associations.rb:1141:in `add_limited_ids_condition!'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord- 1.14.0/lib/<br>&gt; active_record/associations.rb:1131:in<br>&gt; `construct_finder_sql_with_included_associations'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-
1.14.0/lib/<br>&gt; active_record/associations.rb:1094:in `select_all_rows'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/<br>&gt; active_record/associations.rb:960:in `find_with_associations'<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/<br>&gt; active_record/base.rb:923:in `find_every'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/<br>&gt; active_record/base.rb:381:in `find'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/<br>&gt; action_controller/pagination.rb:182:in<br>&gt; `find_collection_for_pagination'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.0
/lib/<br>&gt; action_controller/pagination.rb:198:in `paginator_and_collection_for'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/<br>&gt; action_controller/pagination.rb:129:in `paginate'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/app/controllers/customers_controller.rb:12:in `list'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/<br>&gt; action_controller/base.rb:908:in `perform_action_without_filters'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack- 1.12.0/lib/<br>&gt; action_controller/filters.rb:355:in `perform_action_without_benchmark'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/<br>&gt; action_controller/benchmarking.rb:69:in<br>&gt; `perform_action_without_rescue'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/<br>&gt; action_controller/benchmarking.rb:69:in<br>&gt; `perform_action_without_rescue'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack- 1.12.0
/lib/<br>&gt; action_controller/rescue.rb:82:in `perform_action'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/<br>&gt; action_controller/base.rb:379:in `process_without_filters'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack- 
1.12.0/lib/<br>&gt; action_controller/filters.rb:364:in<br>&gt; `process_without_session_management_support'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/<br>&gt; action_controller/session_management.rb:117:in `process'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/dispatcher.rb:<br>&gt; 38:in `dispatch'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/<br>&gt; fcgi_handler.rb:150:in `process_request'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/rails- 
1.1.0/lib/<br>&gt; fcgi_handler.rb:54:in `process!'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:600:in `each_cgi'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:597:in `each_cgi'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/rails- 
1.1.0/lib/<br>&gt; fcgi_handler.rb:53:in `process!'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/<br>&gt; fcgi_handler.rb:23:in `process!'<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/Users/julian/rails/test/public/dispatch.fcgi:24<br>
&gt;<br>&gt;<br>&gt; Rendering /usr/local/lib/ruby/gems/1.8/gems/actionpack- 1.12.0/lib/<br>&gt; action_controller/templates/rescues/layout.rhtml (500 Internal Error)<br>&gt; _______________________________________________
<br>&gt; Rails mailing list<br>&gt; <a href="mailto:Rails@lists.rubyonrails.org">Rails@lists.rubyonrails.org</a><br>&gt; <a href="http://lists.rubyonrails.org/mailman/listinfo/rails">http://lists.rubyonrails.org/mailman/listinfo/rails
</a><br>&gt; _______________________________________________<br>&gt; Rails mailing list<br>&gt; <a href="mailto:Rails@lists.rubyonrails.org">Rails@lists.rubyonrails.org</a><br>&gt; <a href="http://lists.rubyonrails.org/mailman/listinfo/rails">
http://lists.rubyonrails.org/mailman/listinfo/rails</a><br><br>_______________________________________________<br>Rails mailing list<br><a href="mailto:Rails@lists.rubyonrails.org">Rails@lists.rubyonrails.org</a><br><a href="http://lists.rubyonrails.org/mailman/listinfo/rails">
http://lists.rubyonrails.org/mailman/listinfo/rails</a><br></blockquote></div>