I am using rails just for few days Now i am developing traffic reports for my local network I had to build database queries manualy becouse ActiveRecord does not support selection of multiple sum() fields in silgle query Then i wrote special class QueryBuilder which makes query string from the given conditions (group by, where, additinal fields to select etc). I put QueryBuilder just after my controller file in the same file And now in some cases i have troubles it''s public methods. Class itself is visible, it is passible to create objects of this class, but methods are not accessible after changes in routes.rb Can anyone explain or point me to the related manual how to use own classes which are not a model and not a controller. I cannot extend my model becouse i should have few instances of my class -- Posted via http://www.ruby-forum.com/.
hi> Then i wrote special class QueryBuilder which makes query string from > the given conditions (group by, where, additinal fields to select etc).you should place this code within a model :-)> I put QueryBuilder just after my controller file in the same filethat''s bad, after you''ve moved your code just call the Model.method from the controller Enrico -- "The only thing necessary for the triumph of evil is for good men to do nothing" Edmund Burke
On Apr 20, 2006, at 7:36 AM, Enrico Teotti wrote:>> Then i wrote special class QueryBuilder which makes query string from >> the given conditions (group by, where, additinal fields to select >> etc). > > you should place this code within a model :-)Model? That sounds an awful lot like controller code. Models aren''t supposed to know about the web. :-) How about a helper? -- -- Tom Mornini
> > you should place this code within a model :-) > > Model? That sounds an awful lot like controller code. Models aren''t > supposed to know about the web. :-) > > How about a helper?I assume Kostya is not talking about URL query string, but database queries placed within a string. Otherwise the helper may be fine. :-) -- "The only thing necessary for the triumph of evil is for good men to do nothing" Edmund Burke