Hi, I tried this in my controller @photos = Photo.find(:all, :conditions => [ ''user_id = ?'', @params[:id] ]) but it failed w/ the error ActiveRecord::RecordNotFound in Photos#list Couldn''t find Photo with ID=all AND user_id = ''1'' However this worked. Is there a bug in the documentation? @photos = Photo.find_by_sql [''SELECT * FROM photos WHERE user_id ?'', @params[:id] ] Thanks, Frank
i believe you want Photo.find_by_user_id(@params["id"]) On 4/28/05, Frank Kim <mtmusko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I tried this in my controller > > @photos = Photo.find(:all, :conditions => [ ''user_id = ?'', @params[:id] ]) > > but it failed w/ the error > > ActiveRecord::RecordNotFound in Photos#list > Couldn''t find Photo with ID=all AND user_id = ''1'' > > However this worked. Is there a bug in the documentation? > > @photos = Photo.find_by_sql [''SELECT * FROM photos WHERE user_id > ?'', @params[:id] ] > > Thanks, > Frank > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- ______________ Mike Sugarbaker Super Geiniuis
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Frank Kim wrote:> Hi, > > I tried this in my controller > > @photos = Photo.find(:all, :conditions => [ ''user_id = ?'', @params[:id] ]) > > but it failed w/ the error > > ActiveRecord::RecordNotFound in Photos#list > Couldn''t find Photo with ID=all AND user_id = ''1'' > > However this worked. Is there a bug in the documentation?Do you have the most recent rails? this syntax was introduced in 0.12 I think - -- David Morton Maia Mailguard server side anti-spam/anti-virus solution: http://www.maiamailguard.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCcWiRSIxC85HZHLMRAnHCAKCDGImFDOWkm5k6dW7H1ARgnRucyQCfSPEr 1BXRXcHAB5r1exLGwBqbIm8=PA/P -----END PGP SIGNATURE-----
Ah, I had this confused with that other error about when you get to use the whole ? substitution thing in queries. find_by_user_id might still work though. On 4/28/05, David Morton <mortonda-0/IDydmJJnNeoWH0uzbU5w@public.gmane.org> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Frank Kim wrote: > > Hi, > > > > I tried this in my controller > > > > @photos = Photo.find(:all, :conditions => [ ''user_id = ?'', @params[:id] ]) > > > > but it failed w/ the error > > > > ActiveRecord::RecordNotFound in Photos#list > > Couldn''t find Photo with ID=all AND user_id = ''1'' > > > > However this worked. Is there a bug in the documentation? > > Do you have the most recent rails? this syntax was introduced in 0.12 I > think > > - -- > David Morton > Maia Mailguard server side anti-spam/anti-virus solution: > http://www.maiamailguard.com > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.5 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFCcWiRSIxC85HZHLMRAnHCAKCDGImFDOWkm5k6dW7H1ARgnRucyQCfSPEr > 1BXRXcHAB5r1exLGwBqbIm8> =PA/P > -----END PGP SIGNATURE----- > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- ______________ Mike Sugarbaker Super Geiniuis
Hi, I updated to rails 0.12.1 and it works now. Sorry, I should have tried that first. -Frank On 4/28/05, David Morton <mortonda-0/IDydmJJnNeoWH0uzbU5w@public.gmane.org> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Frank Kim wrote: > > Hi, > > > > I tried this in my controller > > > > @photos = Photo.find(:all, :conditions => [ ''user_id = ?'', @params[:id] ]) > > > > but it failed w/ the error > > > > ActiveRecord::RecordNotFound in Photos#list > > Couldn''t find Photo with ID=all AND user_id = ''1'' > > > > However this worked. Is there a bug in the documentation? > > Do you have the most recent rails? this syntax was introduced in 0.12 I > think > > - -- > David Morton > Maia Mailguard server side anti-spam/anti-virus solution: > http://www.maiamailguard.com > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.5 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFCcWiRSIxC85HZHLMRAnHCAKCDGImFDOWkm5k6dW7H1ARgnRucyQCfSPEr > 1BXRXcHAB5r1exLGwBqbIm8> =PA/P > -----END PGP SIGNATURE----- >