I''m getting some deprecation warnings from some of my forms and I was wondering how exactly I would convert them to the new format so it''s not deprecated. I tried to do what it suggested but it''s not quite that easy...I appreciate any help. Thanks! Warning in the logs: DEPRECATION WARNING: find_all is deprecated and will be removed from Rails 2.0 (use find(:all, ...)) See http://www.rubyonrails.org/deprecation for details. My select box on my form: <p><label for="ticket[priority_id]">Priority</label><br/> <%= select(''ticket'',''priority_id'',Priority.find_all.collect {|p| [ p.priority, p.id ] }, { :prompt => "- Select -" }, { :style => "width: 150px" }) %></p> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damian Terentyev
2007-Jan-28 07:57 UTC
Re: find_all is now deprecated...how do I convert my code?
On Jan 28, 2007, at 10:28, Jl Smith wrote:> I''m getting some deprecation warnings from some of my forms and I was > wondering how exactly I would convert them to the new format so it''s > not > deprecated. I tried to do what it suggested but it''s not quite that > easy...I appreciate any help. Thanks!I just globally replaced find_all with find(:all) in all project files, and it works. Yours may work too: <p><label for="ticket[priority_id]">Priority</label><br/> <%= select(''ticket'',''priority_id'',Priority.find(:all).collect {|p| [ p.priority, p.id ] }, { :prompt => "- Select -" }, { :style => "width: 150px" }) %></p> Your sincerely, Damian/Three-eyed Fish --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well sure enough...thanks again for the tip! On Jan 28, 1:57 am, Damian Terentyev <threeeyedf...-HPQIj1OAFZMvJsYlp49lxw@public.gmane.org> wrote:> On Jan 28, 2007, at 10:28, Jl Smith wrote: > > > I''m getting some deprecation warnings from some of my forms and I was > > wondering how exactly I would convert them to the new format so it''s > > not > > deprecated. I tried to do what it suggested but it''s not quite that > > easy...I appreciate any help. Thanks!I just globally replaced find_all with find(:all) in all project files, > and it works. > > Yours may work too: > > <p><label for="ticket[priority_id]">Priority</label><br/> > <%= select(''ticket'',''priority_id'',Priority.find(:all).collect {|p| [ > p.priority, p.id ] }, { :prompt => "- Select -" }, { :style => "width: > 150px" }) %></p> > > Your sincerely, > Damian/Three-eyed Fish--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jakob Skjerning
2007-Jan-28 12:30 UTC
Re: find_all is now deprecated...how do I convert my code?
On Jan 28, 2007, at 08:28 , Jl Smith wrote:> I''m getting some deprecation warnings from some of my forms and I was > wondering how exactly I would convert them to the new format so > it''s not > deprecated. I tried to do what it suggested but it''s not quite that > easy...I appreciate any help. Thanks![SNIP]> My select box on my form: > <p><label for="ticket[priority_id]">Priority</label><br/> > <%= select(''ticket'',''priority_id'',Priority.find_all.collect {|p| [ > p.priority, p.id ] }, { :prompt => "- Select -" }, { :style => "width: > 150px" }) %></p>Priority.find(:all).collect etc... -- Jakob Skjerning - http://mentalized.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Theron Parlin
2007-Jan-28 13:18 UTC
Re: find_all is now deprecated...how do I convert my code?
>From the command line:find . | grep -i "\.rb$" | xargs ruby -p -i -e ''gsub(/find_all/i, "find(:all)")'' On Jan 28, 7:30 am, Jakob Skjerning <j...-pixy5vpirPnEueBKFXcDjA@public.gmane.org> wrote:> On Jan 28, 2007, at 08:28 , Jl Smith wrote: > > > > > I''m getting some deprecation warnings from some of my forms and I was > > wondering how exactly I would convert them to the new format so > > it''s not > > deprecated. I tried to do what it suggested but it''s not quite that > > easy...I appreciate any help. Thanks! > [SNIP] > > My select box on my form: > > <p><label for="ticket[priority_id]">Priority</label><br/> > > <%= select(''ticket'',''priority_id'',Priority.find_all.collect {|p| [ > > p.priority, p.id ] }, { :prompt => "- Select -" }, { :style => "width: > > 150px" }) %></p>Priority.find(:all).collect etc... > > -- > Jakob Skjerning -http://mentalized.net--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Theron Parlin>>From the command line: > > find . | grep -i "\.rb$" | xargs ruby -p -i -e ''gsub(/find_all/i, > "find(:all)")''Haw haw. That''s a joke, guys. Theron knows that your code should be so well-factored that all your find_all''s only appear in very few places, easy to manually upgrade, and that each one will be too unique to submit do a ''sed'' attack...>> > My select box on my form: >> > <p><label for="ticket[priority_id]">Priority</label><br/> >> > <%= select(''ticket'',''priority_id'',Priority.find_all.collect {|p| [ >> > p.priority, p.id ] }, { :prompt => "- Select -" }, { :style => "width: >> > 150px" }) %></p>Priority.find(:all).collect etc...And while we are on the subject of clean code, all that should be correctly blocked-out and indented, with named variables for intermediate values: <p> <label for="ticket[priority_id]">Priority</label><br/> <% priorities = Priority.find_all.collect{|p| [ p.priority, p.id ] } select ''ticket'', ''priority_id'', priorities, { :prompt => "- Select -" }, { :style => "width: 150px" } %> </p> Much easier to read, understand, and upgrade. Just because Ruby permits these ultra-crunched super-long lines that doesn''t mean we should endure them. Or put them in the Rails books... -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Theron Parlin
2007-Jan-29 01:56 UTC
Re: find_all is now deprecated...how do I convert my code?
Good point Philip, however I had success with it when using it to change @session to session, @param to param, etc.... On Jan 28, 10:24 am, "Phlip" <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Theron Parlin > > >>From the command line: > > > find . | grep -i "\.rb$" | xargs ruby -p -i -e ''gsub(/find_all/i, > > "find(:all)")''Haw haw. That''s a joke, guys. Theron knows that your code should be so > well-factored that all your find_all''s only appear in very few places, easy > to manually upgrade, and that each one will be too unique to submit do a > ''sed'' attack... > > >> > My select box on my form: > >> > <p><label for="ticket[priority_id]">Priority</label><br/> > >> > <%= select(''ticket'',''priority_id'',Priority.find_all.collect {|p| [ > >> > p.priority, p.id ] }, { :prompt => "- Select -" }, { :style => "width: > >> > 150px" }) %></p>Priority.find(:all).collect etc...And while we are on the subject of clean code, all that should be correctly > blocked-out and indented, with named variables for intermediate values: > > <p> > <label for="ticket[priority_id]">Priority</label><br/> > <%> priorities = Priority.find_all.collect{|p| [ p.priority, p.id ] } > select ''ticket'', > ''priority_id'', > priorities, > { :prompt => "- Select -" }, > { :style => "width: 150px" } > %> > </p> > > Much easier to read, understand, and upgrade. Just because Ruby permits > these ultra-crunched super-long lines that doesn''t mean we should endure > them. Or put them in the Rails books... > > -- > Phlip > http://www.greencheese.us/ZeekLand<-- NOT a blog!!!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---