I created some scaffolding for an Address model and an Addresses controller. When running the functional tests for the addresses controller, I get this exception: "NameError: uninitialized constant Addres" The exception seems to start from this function: def list @address_pages, @addresses = paginate :address, :per_page => 10 end I''m guessing pluralization bug? Or did I create the scaffolding wrong? Also (probably unrelated), I''ve generated scaffolding for Orders and Strategies. I''m getting the following exceptions when running the functional tests: 3) Error: test_update(OrdersControllerTest): ActiveRecord::StatementInvalid: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''WHERE id = 1'' at line 1: UPDATE orders SET WHERE id = 1 4) Error: test_update(StrategiesControllerTest): ActiveRecord::StatementInvalid: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''WHERE id = 1'' at line 1: UPDATE strategies SET WHERE id = 1 Are those reserved keywords or something?
On 9/18/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I created some scaffolding for an Address model and an Addresses controller. > > When running the functional tests for the addresses controller, I get > this exception: "NameError: uninitialized constant Addres" > > The exception seems to start from this function: > def list > @address_pages, @addresses = paginate :address, :per_page => 10 > end > > I''m guessing pluralization bug? Or did I create the scaffolding wrong?I did some research on this and found http://dev.rubyonrails.com/ticket/1404. Apparently, the bug was supposedly fixed. But I''m using 0.13.1 and it doesn''t seem fixed all the way yet.> Also (probably unrelated), I''ve generated scaffolding for Orders and > Strategies. I''m getting the following exceptions when running the > functional tests: > > 3) Error: > test_update(OrdersControllerTest): > ActiveRecord::StatementInvalid: You have an error in your SQL syntax; > check the manual that corresponds to your MySQL server version for the > right syntax to use near ''WHERE id = 1'' at line 1: UPDATE orders SET > WHERE id = 1 > > > 4) Error: > test_update(StrategiesControllerTest): > ActiveRecord::StatementInvalid: You have an error in your SQL syntax; > check the manual that corresponds to your MySQL server version for the > right syntax to use near ''WHERE id = 1'' at line 1: UPDATE strategies > SET WHERE id = 1 > > > Are those reserved keywords or something? >
On 9/18/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 9/18/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I created some scaffolding for an Address model and an Addresses controller. > > > > When running the functional tests for the addresses controller, I get > > this exception: "NameError: uninitialized constant Addres" > > > > The exception seems to start from this function: > > def list > > @address_pages, @addresses = paginate :address, :per_page => 10 > > end > > > > I''m guessing pluralization bug? Or did I create the scaffolding wrong?Judging by the method signature of paginate, you need to pass :addresses. It''s probably singularizing it to get the model name. paginate(collection_id, options={}) http://rails.rubyonrails.com/classes/ActionController/Pagination/ClassMethods.html#M000077 -- rick http://techno-weenie.net
On 9/18/05, Rick Olson <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 9/18/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 9/18/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I created some scaffolding for an Address model and an Addresses controller. > > > > > > When running the functional tests for the addresses controller, I get > > > this exception: "NameError: uninitialized constant Addres" > > > > > > The exception seems to start from this function: > > > def list > > > @address_pages, @addresses = paginate :address, :per_page => 10 > > > end > > > > > > I''m guessing pluralization bug? Or did I create the scaffolding wrong? > > Judging by the method signature of paginate, you need to pass > :addresses. It''s probably singularizing it to get the model name. > > paginate(collection_id, options={}) > > http://rails.rubyonrails.com/classes/ActionController/Pagination/ClassMethods.html#M000077Thanks. So the scaffolding code is incorrect here?
On 9/18/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: <snip>> Also (probably unrelated), I''ve generated scaffolding for Orders and > Strategies. I''m getting the following exceptions when running the > functional tests: > > 3) Error: > test_update(OrdersControllerTest): > ActiveRecord::StatementInvalid: You have an error in your SQL syntax; > check the manual that corresponds to your MySQL server version for the > right syntax to use near ''WHERE id = 1'' at line 1: UPDATE orders SET > WHERE id = 1 > > > 4) Error: > test_update(StrategiesControllerTest): > ActiveRecord::StatementInvalid: You have an error in your SQL syntax; > check the manual that corresponds to your MySQL server version for the > right syntax to use near ''WHERE id = 1'' at line 1: UPDATE strategies > SET WHERE id = 1 > > > Are those reserved keywords or something?Thanks to pst on #rubyonrails, I solved this particular problem. The tables for orders and strategies were empty aside from the ''id'' column. Not a particularly informative error though.
> Thanks. So the scaffolding code is incorrect here?Yes, but that patch you linked to should have fixed that if I''m not mistaken. The patch says 0.12.1, but I don''t know when it was fixed. I don''t use scaffolding so I can''t be sure. -- rick http://techno-weenie.net