I''m trying to implement the realtime search box described in the wiki ( http://tinyurl.com/7be4c). The client side stuff works, but I''m getting an error on the server side: NoMethodError in <controller not set>#<action not set> undefined method `const_available?'' for BookController:Class Am I missing simething silly? Here''s the relevant part of the controller: if @params[''search''] @books_pages, @books = paginate :books, :order_by => ''author, title'', :conditions => [ ''LOWER(author) LIKE ?'', ''%'' + @params[''search''].downcase + ''%'' ], :per_page => 20 @mark_term = @params[''search''] else @books_pages, @books = paginate :books, :order_by => ''author, title'', :per_page => 20 end render_without_layout and the view: <input id="search" name="search" type="text" value=""> <%= observe_field ''search'', :frequency => 0.5, :update => ''search_results'', :url => { :controller => ''book_controller'', :action=> ''list'' }, :with => "''search='' + escape(value)" %> <div id="search_results"></div> Thanks! _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
This probably means there is a problem with BookController itself. You might want to check your log (in log/development) to find the exact cause (I''m not sure why the real problem is hidden). You could also try writing a functional tests to run the controller itself - in fact if it''s a syntax error, then running the standard identity functional test which rails generates should highlight the problem (run ''rake test_functional). HTH, sam On 5/3/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m trying to implement the realtime search box described in the wiki > (http://tinyurl.com/7be4c). The client side stuff works, but I''m getting an > error on the server side: > > NoMethodError in <controller not set>#<action not set> > > undefined method `const_available?'' for BookController:Class > > Am I missing simething silly? > > Here''s the relevant part of the controller: > > if @params[''search''] > @books_pages, @books = paginate :books, > :order_by => ''author, title'', > :conditions => [ ''LOWER(author) LIKE ?'', > ''%'' + @params[''search''].downcase + ''%'' ], > :per_page => 20 > @mark_term = @params[''search''] > else > @books_pages, @books = paginate :books, > :order_by => ''author, title'', :per_page => 20 > end > render_without_layout > > > and the view: > > <input id="search" name="search" type="text" value=""> > <%= observe_field ''search'', :frequency => 0.5, > :update => ''search_results'', :url => > { :controller => ''book_controller'', :action=> ''list'' }, > :with => "''search='' + escape(value)" %> > > <div id="search_results"></div> > > > Thanks! > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- sam http://www.magpiebrain.com/
Hey, Sam''s post (Re: Ajax search box question) gave me an idea: why don''t we have an optional section on the error/rescue page that opens up the last 200 lines of the log file? I''m imagining this to look a lot like the current "template variables" section that is closed by default but (by some handy dhtml) opens up to show the log. Errors like this seem to happen often enough that I wish I didn''t have to go to a new terminal and type "tail -f /log/development.log" and then reload the page that caused the error. Any thoughts? Duane Johnson (canadaduane) On May 3, 2005, at 2:51 AM, Sam Newman wrote:> This probably means there is a problem with BookController itself. You > might want to check your log (in log/development) to find the exact > cause (I''m not sure why the real problem is hidden). You could also > try writing a functional tests to run the controller itself - in fact > if it''s a syntax error, then running the standard identity functional > test which rails generates should highlight the problem (run ''rake > test_functional). > > HTH, > > sam > > On 5/3/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> I''m trying to implement the realtime search box described in the wiki >> (http://tinyurl.com/7be4c). The client side stuff works, but I''m >> getting an >> error on the server side: >> >> NoMethodError in <controller not set>#<action not set> >> >> undefined method `const_available?'' for BookController:Class >> >> Am I missing simething silly? >> >> Here''s the relevant part of the controller: >> >> if @params[''search''] >> @books_pages, @books = paginate :books, >> :order_by => ''author, title'', >> :conditions => [ ''LOWER(author) LIKE ?'', >> ''%'' + @params[''search''].downcase + ''%'' ], >> :per_page => 20 >> @mark_term = @params[''search''] >> else >> @books_pages, @books = paginate :books, >> :order_by => ''author, title'', :per_page => 20 >> end >> render_without_layout >> >> >> and the view: >> >> <input id="search" name="search" type="text" value=""> >> <%= observe_field ''search'', :frequency => 0.5, >> :update => ''search_results'', :url => >> { :controller => ''book_controller'', :action=> ''list'' }, >> :with => "''search='' + escape(value)" %> >> >> <div id="search_results"></div> >> >> >> Thanks! >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> >> >> > > > -- > sam > http://www.magpiebrain.com/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
It gets my vote, although would be a potential security hole if you forget to remove the default error pages. Being able to see the full error log makes SQL injection attacks really easy :-) sam On 5/3/05, Duane Johnson <duane.johnson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey, Sam''s post (Re: Ajax search box question) gave me an idea: why > don''t we have an optional section on the error/rescue page that opens > up the last 200 lines of the log file? I''m imagining this to look a > lot like the current "template variables" section that is closed by > default but (by some handy dhtml) opens up to show the log. Errors > like this seem to happen often enough that I wish I didn''t have to go > to a new terminal and type "tail -f /log/development.log" and then > reload the page that caused the error. Any thoughts? > > Duane Johnson > (canadaduane) > > On May 3, 2005, at 2:51 AM, Sam Newman wrote: > > > This probably means there is a problem with BookController itself. You > > might want to check your log (in log/development) to find the exact > > cause (I''m not sure why the real problem is hidden). You could also > > try writing a functional tests to run the controller itself - in fact > > if it''s a syntax error, then running the standard identity functional > > test which rails generates should highlight the problem (run ''rake > > test_functional). > > > > HTH, > > > > sam > > > > On 5/3/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > >> I''m trying to implement the realtime search box described in the wiki > >> (http://tinyurl.com/7be4c). The client side stuff works, but I''m > >> getting an > >> error on the server side: > >> > >> NoMethodError in <controller not set>#<action not set> > >> > >> undefined method `const_available?'' for BookController:Class > >> > >> Am I missing simething silly? > >> > >> Here''s the relevant part of the controller: > >> > >> if @params[''search''] > >> @books_pages, @books = paginate :books, > >> :order_by => ''author, title'', > >> :conditions => [ ''LOWER(author) LIKE ?'', > >> ''%'' + @params[''search''].downcase + ''%'' ], > >> :per_page => 20 > >> @mark_term = @params[''search''] > >> else > >> @books_pages, @books = paginate :books, > >> :order_by => ''author, title'', :per_page => 20 > >> end > >> render_without_layout > >> > >> > >> and the view: > >> > >> <input id="search" name="search" type="text" value=""> > >> <%= observe_field ''search'', :frequency => 0.5, > >> :update => ''search_results'', :url => > >> { :controller => ''book_controller'', :action=> ''list'' }, > >> :with => "''search='' + escape(value)" %> > >> > >> <div id="search_results"></div> > >> > >> > >> Thanks! > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > >> > >> > >> > > > > > > -- > > sam > > http://www.magpiebrain.com/ > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > >-- sam http://www.magpiebrain.com/
Does the search box example work under Internet Explorer? It works fine in everything but IE for me. Thanks, Robbie Sam Newman wrote:> This probably means there is a problem with BookController itself. You > might want to check your log (in log/development) to find the exact > cause (I''m not sure why the real problem is hidden). You could also > try writing a functional tests to run the controller itself - in fact > if it''s a syntax error, then running the standard identity functional > test which rails generates should highlight the problem (run ''rake > test_functional). > > HTH, > > sam > > On 5/3/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>I''m trying to implement the realtime search box described in the wiki >>(http://tinyurl.com/7be4c). The client side stuff works, but I''m getting an >>error on the server side: >> >> NoMethodError in <controller not set>#<action not set> >> >>undefined method `const_available?'' for BookController:Class >> >>Am I missing simething silly? >> >>Here''s the relevant part of the controller: >> >>if @params[''search''] >> @books_pages, @books = paginate :books, >> :order_by => ''author, title'', >> :conditions => [ ''LOWER(author) LIKE ?'', >> ''%'' + @params[''search''].downcase + ''%'' ], >> :per_page => 20 >> @mark_term = @params[''search''] >> else >> @books_pages, @books = paginate :books, >> :order_by => ''author, title'', :per_page => 20 >> end >> render_without_layout >> >> >>and the view: >> >><input id="search" name="search" type="text" value=""> >><%= observe_field ''search'', :frequency => 0.5, >> :update => ''search_results'', :url => >> { :controller => ''book_controller'', :action=> ''list'' }, >> :with => "''search='' + escape(value)" %> >> >><div id="search_results"></div> >> >> >> Thanks! >> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> > > >
Rake _testfunctional works fine: 1 tests, 1 assertions, 0 failures, 0 errors On problem I encountered-- I assume this is a Rake related issue-- is that after running Rake, my mysql table was deleted. Fortunately, I have a fresh backup. Obviously, Rake is not intended to be run on real data. Back to the original issue, here''s my entire controller. Not much there other then what I posted before. Any ideas? Thanks! class BookController < ApplicationController scaffold :book def list @pbooks, @books paginate :book, :order_by => @params[''sort''], :per_page => 20 if @params[''search''] @books_pages, @books = paginate :books, :order_by => ''author, title'', :conditions => [ ''LOWER(author) LIKE ?'', ''%'' + @params[''search''].downcase + ''%'' ], :per_page => 20 @mark_term = @params[''search''] else @books_pages, @books = paginate :books, :order_by => ''author, title'', :per_page => 20 end render_without_layout end end On 5/3/05, Sam Newman <sam.newman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > This probably means there is a problem with BookController itself. You > might want to check your log (in log/development) to find the exact > cause (I''m not sure why the real problem is hidden). You could also > try writing a functional tests to run the controller itself - in fact > if it''s a syntax error, then running the standard identity functional > test which rails generates should highlight the problem (run ''rake > test_functional). > > HTH, > > sam > > On 5/3/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m trying to implement the realtime search box described in the wiki > > (http://tinyurl.com/7be4c). The client side stuff works, but I''m getting > an > > error on the server side: > > > > NoMethodError in <controller not set>#<action not set> > > > > undefined method `const_available?'' for BookController:Class > > > > Am I missing simething silly? > > > > Here''s the relevant part of the controller: > > > > if @params[''search''] > > @books_pages, @books = paginate :books, > > :order_by => ''author, title'', > > :conditions => [ ''LOWER(author) LIKE ?'', > > ''%'' + @params[''search''].downcase + ''%'' ], > > :per_page => 20 > > @mark_term = @params[''search''] > > else > > @books_pages, @books = paginate :books, > > :order_by => ''author, title'', :per_page => 20 > > end > > render_without_layout > > > > > > and the view: > > > > <input id="search" name="search" type="text" value=""> > > <%= observe_field ''search'', :frequency => 0.5, > > :update => ''search_results'', :url => > > { :controller => ''book_controller'', :action=> ''list'' }, > > :with => "''search='' + escape(value)" %> > > > > <div id="search_results"></div> > > > > > > Thanks! > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > -- > sam > http://www.magpiebrain.com/ > _______________________________________________ > 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
Oops. I forgot to attach the tail of the log... On 5/3/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Rake _testfunctional works fine: > 1 tests, 1 assertions, 0 failures, 0 errors > > On problem I encountered-- I assume this is a Rake related issue-- is that > after running Rake, my mysql table was deleted. Fortunately, I have a fresh > backup. Obviously, Rake is not intended to be run on real data. > > Back to the original issue, here''s my entire controller. Not much there > other then what I posted before. Any ideas? > > Thanks! > > class BookController < ApplicationController > scaffold :book > > def list > @pbooks, @books > paginate :book, :order_by => @params[''sort''], :per_page => 20 > > if @params[''search''] > @books_pages, @books = paginate :books, > :order_by => ''author, title'', > :conditions => [ ''LOWER(author) LIKE ?'', > ''%'' + @params[''search''].downcase + ''%'' ], > :per_page => 20 > @mark_term = @params[''search''] > else > @books_pages, @books = paginate :books, > :order_by => ''author, title'', :per_page => 20 > end > render_without_layout > end > end > > > On 5/3/05, Sam Newman <sam.newman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > This probably means there is a problem with BookController itself. You > > might want to check your log (in log/development) to find the exact > > cause (I''m not sure why the real problem is hidden). You could also > > try writing a functional tests to run the controller itself - in fact > > if it''s a syntax error, then running the standard identity functional > > test which rails generates should highlight the problem (run ''rake > > test_functional). > > > > HTH, > > > > sam > > > > On 5/3/05, Mike Payson < mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m trying to implement the realtime search box described in the wiki > > > (http://tinyurl.com/7be4c ). The client side stuff works, but I''m > > getting an > > > error on the server side: > > > > > > NoMethodError in <controller not set>#<action not set> > > > > > > undefined method `const_available?'' for BookController:Class > > > > > > Am I missing simething silly? > > > > > > Here''s the relevant part of the controller: > > > > > > if @params[''search''] > > > @books_pages, @books = paginate :books, > > > :order_by => ''author, title'', > > > :conditions => [ ''LOWER(author) LIKE ?'', > > > ''%'' + @params[''search''].downcase + ''%'' ], > > > :per_page => 20 > > > @mark_term = @params[''search''] > > > else > > > @books_pages, @books = paginate :books, > > > :order_by => ''author, title'', :per_page => 20 > > > end > > > render_without_layout > > > > > > > > > and the view: > > > > > > <input id="search" name="search" type="text" value=""> > > > <%= observe_field ''search'', :frequency => 0.5, > > > :update => ''search_results'', :url => > > > { :controller => ''book_controller'', :action=> ''list'' }, > > > :with => "''search='' + escape(value)" %> > > > > > > <div id="search_results"></div> > > > > > > > > > Thanks! > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > -- > > sam > > http://www.magpiebrain.com/ > > _______________________________________________ > > 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
Kristofer Goss
2005-May-03 17:07 UTC
Re: Re: Why not add the log file to the rescue template?
Sam, doesn''t ActiveRecord protect against SQL injection attacks already? I recall seeing sanitize_sql somewhere in the source. I''m noob to MySQL but with SQL Server/ADO(.NET) the best practice is to always use parameterized queries. I was wondering if this is a risk currently. -Kris On 5/3/05, Sam Newman <sam.newman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > It gets my vote, although would be a potential security hole if you > forget to remove the default error pages. Being able to see the full > error log makes SQL injection attacks really easy :-) > > sam > > On 5/3/05, Duane Johnson <duane.johnson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hey, Sam''s post (Re: Ajax search box question) gave me an idea: why > > don''t we have an optional section on the error/rescue page that opens > > up the last 200 lines of the log file? I''m imagining this to look a > > lot like the current "template variables" section that is closed by > > default but (by some handy dhtml) opens up to show the log. Errors > > like this seem to happen often enough that I wish I didn''t have to go > > to a new terminal and type "tail -f /log/development.log" and then > > reload the page that caused the error. Any thoughts? > > > > Duane Johnson > > (canadaduane) > > > > On May 3, 2005, at 2:51 AM, Sam Newman wrote: > > > > > This probably means there is a problem with BookController itself. You > > > might want to check your log (in log/development) to find the exact > > > cause (I''m not sure why the real problem is hidden). You could also > > > try writing a functional tests to run the controller itself - in fact > > > if it''s a syntax error, then running the standard identity functional > > > test which rails generates should highlight the problem (run ''rake > > > test_functional). > > > > > > HTH, > > > > > > sam > > > > > > On 5/3/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > >> I''m trying to implement the realtime search box described in the wiki > > >> (http://tinyurl.com/7be4c). The client side stuff works, but I''m > > >> getting an > > >> error on the server side: > > >> > > >> NoMethodError in <controller not set>#<action not set> > > >> > > >> undefined method `const_available?'' for BookController:Class > > >> > > >> Am I missing simething silly? > > >> > > >> Here''s the relevant part of the controller: > > >> > > >> if @params[''search''] > > >> @books_pages, @books = paginate :books, > > >> :order_by => ''author, title'', > > >> :conditions => [ ''LOWER(author) LIKE ?'', > > >> ''%'' + @params[''search''].downcase + ''%'' ], > > >> :per_page => 20 > > >> @mark_term = @params[''search''] > > >> else > > >> @books_pages, @books = paginate :books, > > >> :order_by => ''author, title'', :per_page => 20 > > >> end > > >> render_without_layout > > >> > > >> > > >> and the view: > > >> > > >> <input id="search" name="search" type="text" value=""> > > >> <%= observe_field ''search'', :frequency => 0.5, > > >> :update => ''search_results'', :url => > > >> { :controller => ''book_controller'', :action=> ''list'' }, > > >> :with => "''search='' + escape(value)" %> > > >> > > >> <div id="search_results"></div> > > >> > > >> > > >> Thanks! > > >> > > >> _______________________________________________ > > >> Rails mailing list > > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > >> > > >> > > >> > > >> > > > > > > > > > -- > > > sam > > > http://www.magpiebrain.com/ > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > -- > sam > http://www.magpiebrain.com/ > _______________________________________________ > 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
The problem I''m having is server-side, so the browser shouldn''t matter. I did test it in IE after getting your email, and the client-side stuff didn''t work there for me either, but it appears to be a completely seperate issue. On 5/3/05, Robbie Bingler <tripodrob-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Does the search box example work under Internet Explorer? It works fine > in everything but IE for me. > > Thanks, > Robbie > > Sam Newman wrote: > > This probably means there is a problem with BookController itself. You > > might want to check your log (in log/development) to find the exact > > cause (I''m not sure why the real problem is hidden). You could also > > try writing a functional tests to run the controller itself - in fact > > if it''s a syntax error, then running the standard identity functional > > test which rails generates should highlight the problem (run ''rake > > test_functional). > > > > HTH, > > > > sam > > > > On 5/3/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >>I''m trying to implement the realtime search box described in the wiki > >>(http://tinyurl.com/7be4c). The client side stuff works, but I''m getting an > >>error on the server side: > >> > >> NoMethodError in <controller not set>#<action not set> > >> > >>undefined method `const_available?'' for BookController:Class > >> > >>Am I missing simething silly? > >> > >>Here''s the relevant part of the controller: > >> > >>if @params[''search''] > >> @books_pages, @books = paginate :books, > >> :order_by => ''author, title'', > >> :conditions => [ ''LOWER(author) LIKE ?'', > >> ''%'' + @params[''search''].downcase + ''%'' ], > >> :per_page => 20 > >> @mark_term = @params[''search''] > >> else > >> @books_pages, @books = paginate :books, > >> :order_by => ''author, title'', :per_page => 20 > >> end > >> render_without_layout > >> > >> > >>and the view: > >> > >><input id="search" name="search" type="text" value=""> > >><%= observe_field ''search'', :frequency => 0.5, > >> :update => ''search_results'', :url => > >> { :controller => ''book_controller'', :action=> ''list'' }, > >> :with => "''search='' + escape(value)" %> > >> > >><div id="search_results"></div> > >> > >> > >> Thanks! > >> > >>_______________________________________________ > >>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 Wednesday, May 4, 2005, 12:04:03 AM, Duane wrote:> Hey, Sam''s post (Re: Ajax search box question) gave me an idea: why > don''t we have an optional section on the error/rescue page that opens > up the last 200 lines of the log file? I''m imagining this to look a > lot like the current "template variables" section that is closed by > default but (by some handy dhtml) opens up to show the log. Errors > like this seem to happen often enough that I wish I didn''t have to go > to a new terminal and type "tail -f /log/development.log" and then > reload the page that caused the error. Any thoughts?Yeah, here''s a thought. Use ''less'' instead of ''tail''. Then you won''t need to reload the page. Once in ''less'', hit F to poll for updates (like tail -f). The general ignorance of this feature of ''less'' astounds me, until I remember that I only learned it by chance. (Before flaming, recall that "ignorant" is not a dirty or loaded word. It simply means "not knowing".) But I like the idea of including some of the log in the errors page. Further, the bits of that page that are selectively opened should be able to be closed again. Gavin
I just added a patch ticket at http://dev.rubyonrails.com/ticket/1252 . We''ll see if it gets in to the next release! :) Duane Johnson (canadaduane) On 5/3/05, Gavin Sinclair <gsinclair-81uBx+iSpXA0n/F98K4Iww@public.gmane.org> wrote:> On Wednesday, May 4, 2005, 12:04:03 AM, Duane wrote: > > > Hey, Sam''s post (Re: Ajax search box question) gave me an idea: why > > don''t we have an optional section on the error/rescue page that opens > > up the last 200 lines of the log file? I''m imagining this to look a > > lot like the current "template variables" section that is closed by > > default but (by some handy dhtml) opens up to show the log. Errors > > like this seem to happen often enough that I wish I didn''t have to go > > to a new terminal and type "tail -f /log/development.log" and then > > reload the page that caused the error. Any thoughts? > > Yeah, here''s a thought. Use ''less'' instead of ''tail''. Then you won''t > need to reload the page. Once in ''less'', hit F to poll for updates > (like tail -f). > > The general ignorance of this feature of ''less'' astounds me, until I > remember that I only learned it by chance. (Before flaming, recall > that "ignorant" is not a dirty or loaded word. It simply means "not > knowing".) > > But I like the idea of including some of the log in the errors page. > Further, the bits of that page that are selectively opened should be > able to be closed again. > > Gavin > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Duane Johnson (canadaduane)
Michael Koziarski
2005-May-04 04:43 UTC
Re: Why not add the log file to the rescue template?
On 5/4/05, Duane Johnson <duane.johnson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I just added a patch ticket at http://dev.rubyonrails.com/ticket/1252 > . We''ll see if it gets in to the next release! :)Thanks for the patch, and I''m sure it''ll get reviewed in due course, However... "I''m imagining this to look a lot like the current "template variables" section that is closed by default but (by some handy dhtml) opens up to show the log." We just took the template variables out of the error page. http://dev.rubyonrails.org/changeset/1246> Duane Johnson > (canadaduane) > > On 5/3/05, Gavin Sinclair <gsinclair-81uBx+iSpXA0n/F98K4Iww@public.gmane.org> wrote: > > On Wednesday, May 4, 2005, 12:04:03 AM, Duane wrote: > > > > > Hey, Sam''s post (Re: Ajax search box question) gave me an idea: why > > > don''t we have an optional section on the error/rescue page that opens > > > up the last 200 lines of the log file? I''m imagining this to look a > > > lot like the current "template variables" section that is closed by > > > default but (by some handy dhtml) opens up to show the log. Errors > > > like this seem to happen often enough that I wish I didn''t have to go > > > to a new terminal and type "tail -f /log/development.log" and then > > > reload the page that caused the error. Any thoughts? > > > > Yeah, here''s a thought. Use ''less'' instead of ''tail''. Then you won''t > > need to reload the page. Once in ''less'', hit F to poll for updates > > (like tail -f). > > > > The general ignorance of this feature of ''less'' astounds me, until I > > remember that I only learned it by chance. (Before flaming, recall > > that "ignorant" is not a dirty or loaded word. It simply means "not > > knowing".) > > > > But I like the idea of including some of the log in the errors page. > > Further, the bits of that page that are selectively opened should be > > able to be closed again. > > > > Gavin > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > -- > Duane Johnson > (canadaduane) > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
On May 3, 2005, at 12:37 AM, Mike Payson wrote:> I''m trying to implement the realtime search box described in the > wiki (http://tinyurl.com/7be4c).Just in case it helps, I offer up: http://phrogz.net/JS/Filterlicious/index.html http://phrogz.net/JS/Filterlicious/simpletable.html (you can hork files from the directory listing: http://phrogz.net/JS/ Filterlicious/ ) _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Koz said:> We just took the template variables out of the error page. > > http://dev.rubyonrails.org/changeset/1246It''s true that it was used "rarely", but on occasion it was a very handy feature. I wonder if it might be possible (instead of removing the feature entirely) to add a link to another page that would then load and display the template variables? That might be the best of both worlds. Architecturally, would this be a lot of work, Koz? As for the log file patch, the amount of "tail" that the new code reads in is always the same, so I don''t anticipate there being an undesirable side effect as in the case of extremely large template variables. Duane Johnson (canadaduane)
Another idea I''ve been meaning to try is using the TrimPath libraries: http://trimpath.com/. - Retrieve data from server via AJAX call in JSON format - Use TrimQuery to filter that data using SQL-like syntax - Use Javascript Templates to display the data. Before Rails added its Ajax support, I had something very similar working. Type in ''a'' and it loaded all the ''a'' data into the browser. Then, as you typed it filtered the list and displayed it underneath. After the inital data load (which was as fast as a Rails call can be), it was nice and speedy. On 5/4/05, Gavin Kistner <gavin-XtLdkLkwz3ZWk0Htik3J/w@public.gmane.org> wrote:> > On May 3, 2005, at 12:37 AM, Mike Payson wrote: > I''m trying to implement the realtime search box described in the wiki > (http://tinyurl.com/7be4c). > Just in case it helps, I offer up: > http://phrogz.net/JS/Filterlicious/index.html > http://phrogz.net/JS/Filterlicious/simpletable.html > > (you can hork files from the directory listing: > http://phrogz.net/JS/Filterlicious/ ) > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- rick http://techno-weenie.net
Mike Payson wrote:> I''m trying to implement the realtime search box described in the wiki ( > http://tinyurl.com/7be4c). The client side stuff works, but I''m getting an > error on the server side:OK, I''m not the only one. Bear with me I am looooong time since I did anything that wasn''t procedural, so maybe I am just not getting it. Currently I think the realtime search box example is supposed to work like this, it really isn''t too clear. I have in my controller (accountsfind_controller.rb) ----------------------------------------------------- class AccountsfindController < ApplicationController def index @clients = Client.find(:all) end def list if @params[''search''] @clients_list, @clients = paginate :clients, :order_by => ''company_name'', :conditions => [''LOWER(company_name) LIKE ?'', ''%'' + @params[''search''].downcase + ''%'' ], :per_page => 20 @mark_term = @params[''search''] else @clients_list, @clients = paginate :clients, :order_by => ''company_name'', :per_page => 20 end render_without_layout end end In my view I have (views/accountsfind/index.rhtml) -------------------------------------------------- <h1>Select Account</h1> <% define_javascript_functions %> <%= javascript_include_tag "prototype" %> <input id=''search'' name=''search'' type=''text'' value=''''> <%= observe_field ''search'', :frequency => 0.5, :update => ''target_id'', :url => {:controller => ''accountsfind'', :action => ''lis t''}, :with => "''search='' + escape(value)" %> <div id=''target_id''> </div> And in my list view I have (views/accountsfind/list.rhtml) --------------------------------------------------------- <%= @mark_term ? highlight(client.company_name, @mark_term) : h(client.company_name) %> And everytime I enter a search I get back, --------------------------------------------------------- undefined local variable or method `client'' for #<ActionView::Base:0xa6cea80> Obviously I need to get the results of the search into list.rhtml but I''ll be darned if I can see how. I understand that the syntax is not right in list.rthml as "client" is not defined. So what holds the value of the search results? I can see where I create the clients object, populate it with the contents of Clients.find(:all). I understand how the list method is taking @clients and searching through it to create @clients_list. I understand how the action in the index view is calling the list method of the accountsfind controller (with the search params). I even think I understand how observe_field is using that object to update "target_id". (Feel free to point out where my understanding falls apart) I don''t understand how I get the results into the list view. Any clues? Thanks, DAve
On 5/4/05, DAve <dave.list-+JIuMJIPudMuIF41do6k7w@public.gmane.org> wrote:> > Mike Payson wrote: > > I''m trying to implement the realtime search box described in the wiki ( > > http://tinyurl.com/7be4c). The client side stuff works, but I''m getting > an > > error on the server side: > > OK, I''m not the only one. Bear with me I am looooong time since I did > anything that wasn''t procedural, so maybe I am just not getting it. > > Currently I think the realtime search box example is supposed to work > like this, it really isn''t too clear. > > I have in my controller (accountsfind_controller.rb) > ----------------------------------------------------- > class AccountsfindController < ApplicationController > > def index > @clients = Client.find(:all) > end > > def list > if @params[''search''] > @clients_list, @clients = paginate :clients, :order_by => > ''company_name'', :conditions => [''LOWER(company_name) LIKE ?'', > ''%'' + @params[''search''].downcase + ''%'' ], :per_page => 20 > @mark_term = @params[''search''] > else > @clients_list, @clients = paginate :clients, :order_by => > ''company_name'', :per_page => 20 > end > render_without_layout > end > > end > > In my view I have (views/accountsfind/index.rhtml) > -------------------------------------------------- > <h1>Select Account</h1> > > <% define_javascript_functions %> > <%= javascript_include_tag "prototype" %> > > <input id=''search'' name=''search'' type=''text'' value=''''> > <%= observe_field ''search'', :frequency => 0.5, :update => ''target_id'', > :url => {:controller => ''accountsfind'', :action => ''lis > t''}, :with => "''search='' + escape(value)" %> > <div id=''target_id''> > </div> > > And in my list view I have (views/accountsfind/list.rhtml) > --------------------------------------------------------- > <%= @mark_term ? highlight(client.company_name, @mark_term) : > h(client.company_name) %> > > And everytime I enter a search I get back, > --------------------------------------------------------- > undefined local variable or method `client'' for > #<ActionView::Base:0xa6cea80> > > Obviously I need to get the results of the search into list.rhtml but > I''ll be darned if I can see how. I understand that the syntax is not > right in list.rthml as "client" is not defined. So what holds the value > of the search results? > > I can see where I create the clients object, populate it with the > contents of Clients.find(:all). I understand how the list method is > taking @clients and searching through it to create @clients_list. I > understand how the action in the index view is calling the list method > of the accountsfind controller (with the search params). I even think I > understand how observe_field is using that object to update "target_id". > > (Feel free to point out where my understanding falls apart) > > I don''t understand how I get the results into the list view. Any clues?Hi Dave, I''m not sure what the source of your error is, but I can help clear the basic functionality up a bit. You don''t need to worry about updating your list.rhtml or getting the reults into the view. That happens automatically. The Javascript will automatically populate the target_id div with the search results. That''s the beauty of Ajax is it does it in real time, without needing to reload the page. BTW, I still need a solution to my problem if anyone has any ideas. Thanks! Mike _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Mike Payson wrote:> On 5/4/05, DAve <dave.list-+JIuMJIPudMuIF41do6k7w@public.gmane.org> wrote: > >>Mike Payson wrote: >><snip>>>@clients_list, @clients = paginate :clients, :order_by => >>''company_name'', :conditions => [''LOWER(company_name) LIKE ?'', >>''%'' + @params[''search''].downcase + ''%'' ], :per_page => 20> > Hi Dave, > > I''m not sure what the source of your error is, but I can help clear the > basic functionality up a bit. You don''t need to worry about updating your > list.rhtml or getting the reults into the view. That happens automatically. > The Javascript will automatically populate the target_id div with the search > results. That''s the beauty of Ajax is it does it in real time, without > needing to reload the page. >Neither do I ;^) I finally threw out the example and started from scratch and it is working quite well now. Though I will post a related question under another thread. There is one part of the code I don''t get, I looked through the Pickaxe and a few examples with no epiphany. @clients_list, @clients = paginate :clients, :order_by => ''company_name'', :conditions => [''LOWER(company_name) LIKE ?'', ''%'' + @params[''search''].downcase + ''%'' ], :per_page => 20 Specificly, <OBJ>, <OBJ> = <some_code> Can ya help a guy out?> BTW, I still need a solution to my problem if anyone has any ideas. >I wish I could help. Currently I am struggling with the lack of current OOP skills, terminology changes, data modeling (didn''t have that when I was using "messaging"). Though writing code always has been the best teacher and it is proving itself true now. On a side note, I had an instructor (in 1979!) who use to say "it''s finished when you can remove no more code". Rails seems to like that, so do I. DAve
> There is one part of the code I don''t get, I looked through the Pickaxe > and a few examples with no epiphany. > > @clients_list, @clients = paginate :clients, :order_by => > ''company_name'', :conditions => [''LOWER(company_name) LIKE ?'', > ''%'' + @params[''search''].downcase + ''%'' ], :per_page => 20 > > Specificly, > > <OBJ>, <OBJ> = <some_code> >This is because Ruby supports returning multiple values. irb(main):001:0> def foo irb(main):002:1> return 1,2 irb(main):003:1> end => nil irb(main):004:0> a, b = foo => [1, 2] irb(main):005:0> a => 1 irb(main):006:0> b => 2 So whats happening is you call the paginate method with several parameters, and it returns you two objects: a paginator object, and a collection of records. Everything after "paginate" are parameters to that method, which could be made more explicit by using parens but is perfectly acceptable the way it is. HTH, Jason
Jason Foreman wrote:>>There is one part of the code I don''t get, I looked through the Pickaxe >>and a few examples with no epiphany. >> >>@clients_list, @clients = paginate :clients, :order_by => >>''company_name'', :conditions => [''LOWER(company_name) LIKE ?'', >>''%'' + @params[''search''].downcase + ''%'' ], :per_page => 20 >> >>Specificly, >> >><OBJ>, <OBJ> = <some_code> >> > > > This is because Ruby supports returning multiple values.Excellent, got it.> > irb(main):001:0> def foo > irb(main):002:1> return 1,2 > irb(main):003:1> end > => nil > irb(main):004:0> a, b = foo > => [1, 2] > irb(main):005:0> a > => 1 > irb(main):006:0> b > => 2 > > > So whats happening is you call the paginate method with several > parameters, and it returns you two objects: a paginator object, and a > collection of records. Everything after "paginate" are parameters to > that method, which could be made more explicit by using parens but is > perfectly acceptable the way it is.@clients_list, @clients = paginate (:clients, :order_by => ''company_name'', :conditions => [''LOWER(company_name) LIKE ?'', ''%'' + @params[''search''].downcase + ''%'' ], :per_page => 20) Now I know where to look! http://api.rubyonrails.com/classes/ActionController/Pagination.html#M000067 Thank you very much. DAve
Gavin Kistner wrote:> On May 3, 2005, at 12:37 AM, Mike Payson wrote: > >> I''m trying to implement the realtime search box described in the wiki >> (http://tinyurl.com/7be4c). > > Just in case it helps, I offer up: > http://phrogz.net/JS/Filterlicious/index.html > http://phrogz.net/JS/Filterlicious/simpletable.html >Hi, I''ve been using this, thanks for posting it. I do however have a couple of questions... I''ve set my page up so that there''s a searchbox and a list of names. On each name is a link that submits an AJAX request when you click on it, replacing the list with a hidden field for the person_id and their details below. As well as the details I''ve got a cancel link that returns the list of names, ie to go back when you select the wrong person. Here''s the problem - when the list comes back the search no longer works! Any idea how to overcome that? I''d also like to set a maximim limit on the number shown in the list, so when a search is too general it just says "X results found" but I suspect that''s just some simple javascript hacking. Cheers, Mark