I think I must be missing something obvious... I have... class OrderController < ApplicationController model :order scaffold :order def list @orders = Order.find_all_by_status(@params[:status], :order => "date" ) end end class Order < ActiveRecord::Base belongs_to :customer end and i''m getting... /Unknown column ''orderdate'' in ''order clause'': SELECT * FROM orders WHERE status = ''New'' ORDER BY orderdate/ Why is it appending the model name to the front of the :order sort clause? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I was having the same problem with any :condition, :order or whatever being passed in to the sql query like you show. i.e. :token => "value" was passed to the sql statement as "tokenvalue" and throwing a sql syntax error. I don''t know why it wasn''t working, but found that running "gem update" solved the problem. On Apr 20, 2005, at 3:50 PM, Sean T Allen wrote:> I think I must be missing something obvious... > > I have... > > class OrderController < ApplicationController > model :order > scaffold :order > > def list > @orders = Order.find_all_by_status(@params[:status], :order => > "date" ) > end > end > > class Order < ActiveRecord::Base > belongs_to :customer > end > > and i''m getting... > > Unknown column ''orderdate'' in ''order clause'': SELECT * FROM orders > WHERE status = ''New'' ORDER BY orderdate > > Why is it appending the model name to the front of the :order sort > clause? > > <sean.vcf> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 4.5.2005, at 03:44, Craig Beck wrote:> I was having the same problem with any :condition, :order or whatever > being passed in to the sql query like you show. > > i.e. :token => "value" was passed to the sql statement as "tokenvalue" > and throwing a sql syntax error. > > I don''t know why it wasn''t working, but found that running "gem > update" solved the problem.It''s because the syntax of the find method changed in one of the latest AR updates. //jarkko -- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Jarkko Laine wrote:> On 4.5.2005, at 03:44, Craig Beck wrote: > >> I was having the same problem with any :condition, :order or whatever >> being passed in to the sql query like you show. >> >> i.e. :token => "value" was passed to the sql statement as >> "tokenvalue" and throwing a sql syntax error. >> >> I don''t know why it wasn''t working, but found that running "gem >> update" solved the problem. > > > It''s because the syntax of the find method changed in one of the > latest AR updates. >What is the new syntax because api.rubyonrails.com apparently hasnt been updated... to quote /It’s even possible to use all the additional parameters to find. For example, the full interface for Payment.find_all_by_amount is actually Payment.find_all_by_amount(amount, options). And the full interface to Person.find_by_user_name is actually Person.find_by_user_name(user_name, options). So you could call Payment.find_all_by_amount(50, :order => "created_on")./ _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sean, On 4.5.2005, at 14:57, Sean T Allen wrote:>> > What is the new syntax because api.rubyonrails.com apparently hasnt > been updated... > > to quote > > /It’s even possible to use all the additional parameters to find. For > example, the full interface for Payment.find_all_by_amount is actually > Payment.find_all_by_amount(amount, options). And the full interface to > Person.find_by_user_name is actually > Person.find_by_user_name(user_name, options). So you could call > Payment.find_all_by_amount(50, :order => "created_on")./Well, that is exactly the new syntax (which uses hash for all the options) :-) It''s explained in detail in the find method (http://rails.rubyonrails.com/classes/ActiveRecord/Base.html#M000650). //jarkko> <sean.vcf>_______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Then please explain how: Payment.find_all_by_amount(50, :order => "created_on" ) is different from Order.find_all_by_status(@params[:status], :order => "date" ) which is what keeps blowing up on me... Jarkko Laine wrote:> Sean, > > On 4.5.2005, at 14:57, Sean T Allen wrote: > >>> >> What is the new syntax because api.rubyonrails.com apparently hasnt >> been updated... >> >> to quote >> >> /It’s even possible to use all the additional parameters to find. For >> example, the full interface for Payment.find_all_by_amount is >> actually Payment.find_all_by_amount(amount, options). And the full >> interface to Person.find_by_user_name is actually >> Person.find_by_user_name(user_name, options). So you could call >> Payment.find_all_by_amount(50, :order => "created_on")./ > > > Well, that is exactly the new syntax (which uses hash for all the > options) :-) It''s explained in detail in the find method > (http://rails.rubyonrails.com/classes/ActiveRecord/Base.html#M000650). > > //jarkko > >> <sean.vcf>_______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > -- > Jarkko Laine > http://jlaine.net > http://odesign.fi > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 4.5.2005, at 15:20, Sean T Allen wrote:> Then please explain how: > > Payment.find_all_by_amount(50, :order => "created_on" ) > > is different from > > Order.find_all_by_status(@params[:status], :order => "date" ) > > which is what keeps blowing up on me...I don''t know what''s causing that specific problem, but the reason for some people in this thread was that they tried to use the new syntax without first updating ActiveRecord gems. They then noticed that updating fixed the problem and asked why updating fixed it. My post was an answer to that question. As for your problem, I can''t see anything weird in the syntax. You sure you have the latest gems? //jarkko -- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
yeah... only have the issue on one machine... its a dev box and things are early on... thinking of jsut wiping the ruby and rails installs and doing them over... 15 minutes of my life... and the potential savings is rather large... Jarkko Laine wrote:> On 4.5.2005, at 15:20, Sean T Allen wrote: > >> Then please explain how: >> >> Payment.find_all_by_amount(50, :order => "created_on" ) >> >> is different from >> >> Order.find_all_by_status(@params[:status], :order => "date" ) >> >> which is what keeps blowing up on me... > > > I don''t know what''s causing that specific problem, but the reason for > some people in this thread was that they tried to use the new syntax > without first updating ActiveRecord gems. They then noticed that > updating fixed the problem and asked why updating fixed it. My post > was an answer to that question. > > As for your problem, I can''t see anything weird in the syntax. You > sure you have the latest gems? > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://odesign.fi > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails