Quoted below is an exchange between two rails list members, followed by some thoughts I''ve just had concerning the community in general, where it might be headed and what that means to professional users of Ruby on Rails in general now and into the future.> On Oct 4, 2005, at 6:33 PM, Duane Johnson wrote: > >> On Oct 4, 2005, at 4:27 PM, Chris Cothrun wrote: > >>> I''ve diving into Rails and have a question about >>> grabbing the values in a hash submitted by a formsnip relevant and insightful response...>> Alternatively, (and assuming you are editing a user with >> your form, and that you have somewhere in your form a >> hidden input field named ''id'' with a value set to the id >> of the user)Or your form was created as such in your view... <%= start_form_tag :controller => ''Object'', :action => :create, :id => @object %> and your config/routes.rb file is the default one, or similar enough that that :controller/:action/:id location will map this way: # Install the default route as the lowest priority. map.connect '':controller/:action/:id'' In fact, from the code generated by ./script/generate scaffolding Model I dare say that the URL method would be considered more ''On the Rails.'' by both DHH and Dave Thomas if the proof of the code, the great intro videos, and the fantastic samples and explanation thereof in the book would be considered the ''norm.'' The beauty of Ruby on Rails is in the Rails, not the Ruby per se. I think it is implicit in the recitation of DRY that we have the responsibility this time around (web 2.0) to have every developer in this system speak in unison as to the community standard processes and methods of web applications development that went so haywire the first time around in the space approximately matched by Perl in terms of expression and runtime dynamics on one side, raw pragmatic practicality on another side and ease of development and pure transparency and approachability of PHP on another. Those languages did pretty well last time around, if you think about it and throw away your distaste of any or all of them in one form or another. Image how much return on investment we''ll all get each time we need to support someone else''s application if we all STAY ON THE RAILS. Imagine! Entire systems built around MVC the Rails way, from Web to SysAdmin thanks script/runner. And all we have to do is listen carefully to the folks leading by example and amplify their message by responding and interacting with them until we''re all doing whatever it is we can do to help by testing, coding, marketing, selling etc. (whatever it is you''re good at!) to drive the development and acceptance of Rails as a platform and distributing that platform over and over again over the next 10 years. I''m not suggesting that any or all of us "sit down and shut up" in any way shape or form, but I *am* suggesting that the reason interest is skyrocketiing in this corner of the universe is because DHH writes less code and has more opinions than perhaps any other person on the planet willing to share them along with actual no BS implementations that prove beyond a shadow of a doubt that his opinions are practical beyond all else. Please everyone, before showing someone how to do something that is off the Rails, think twice about why the Rails exist to begin with! Thanks, DHH, for giving us a wonderful, opinionated thing. Thanks, Pragmatic Guys, for documenting it so very well. -- -- Tom Mornini _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Oct 6, 2005, at 1:06 AM, Tom Mornini wrote:> Quoted below is an exchange between two rails list > members, followed by some thoughts I''ve just had > concerning the community in general, where it might > be headed and what that means to professional users > of Ruby on Rails in general now and into the future. > >> On Oct 4, 2005, at 6:33 PM, Duane Johnson wrote: >> >>> On Oct 4, 2005, at 4:27 PM, Chris Cothrun wrote: >> >>>> I''ve diving into Rails and have a question about >>>> grabbing the values in a hash submitted by a form > > snip relevant and insightful response... > >>> Alternatively, (and assuming you are editing a user with >>> your form, and that you have somewhere in your form a >>> hidden input field named ''id'' with a value set to the id >>> of the user) > > Or your form was created as such in your view... > > <%= start_form_tag :controller => ''Object'', > :action => :create, > :id => @object %> >Well, you learn something new every day. Duane _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 10/6/05, Tom Mornini <tmornini-W/9V78bTXriB+jHODAdFcQ@public.gmane.org> wrote:> > Quoted below is an exchange between two rails list > members, followed by some thoughts I''ve just had > concerning the community in general, where it might > be headed and what that means to professional users > of Ruby on Rails in general now and into the future.<snip> OK, as the original poster I''ll bring this full circle by clarifying my original question and asking for some additional insight into the Rails way of achieving what I want. I''m looking up people in a database by phone number, I don''t have the id of their record in the database yet, I want to get that so I can add additional information, etc. So my form is currently like: <form method="post" action="lookupphone"> <%= text_field("client", "phone") %> <input type="submit" value="Search"> </form> and lookupphone in my controller is: def lookupphone @phonenumber = params[:client][:phone] @results = Client.find(:first, :conditions => ["phone = ? or phone2 = ? ", @phonenumber, @phonenumber]) if @results.nil? flash[:notice] = "Phone Number not found" redirect_to(:action => ''sales'') end end I can already see that I can read up on the form helpers to clean up the way I''m creating the forums. I know there are a couple of ways to specify the database :conditions. What else can I look at doing to stay on the Rails? -- - Chris
On 10/8/05, Chris Cothrun <mutagen@gmail.com> wrote:> What else can I look at doing to > stay on the Rails?Write unit tests. -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Some comments which may or may not be of use - sorry if some of this is off the rails as I''m only at novice+1 level ;D 1) be clear in your own mind regarding variable scope ... In your example, are @phonenumber and @results reused at all [ie, in the view] ? If not, drop the @ 2) You can shorten \if @results.nil?\ to simply \if @results\. 3) \redirect_to(:action => ''sales'')\ might not work as you expect [if you expect the action to finish at that point]. The method will continue being processed, sometimes resulting in a ''double render exception'' I tend to use \redirect_to(:action => ''sales'') and return\ to be clear that the action has completed -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Chris Cothrun Sent: Sunday, 9 October 2005 1:47 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] We all need to stay on the Rails On 10/6/05, Tom Mornini <tmornini-W/9V78bTXriB+jHODAdFcQ@public.gmane.org> wrote:> > Quoted below is an exchange between two rails list members, followed > by some thoughts I''ve just had concerning the community in general, > where it might be headed and what that means to professional users of > Ruby on Rails in general now and into the future.<snip> OK, as the original poster I''ll bring this full circle by clarifying my original question and asking for some additional insight into the Rails way of achieving what I want. I''m looking up people in a database by phone number, I don''t have the id of their record in the database yet, I want to get that so I can add additional information, etc. So my form is currently like: <form method="post" action="lookupphone"> <%= text_field("client", "phone") %> <input type="submit" value="Search"> </form> and lookupphone in my controller is: def lookupphone @phonenumber = params[:client][:phone] @results = Client.find(:first, :conditions => ["phone = ? or phone2 = ? ", @phonenumber, @phonenumber]) if @results.nil? flash[:notice] = "Phone Number not found" redirect_to(:action => ''sales'') end end I can already see that I can read up on the form helpers to clean up the way I''m creating the forums. I know there are a couple of ways to specify the database :conditions. What else can I look at doing to stay on the Rails? -- - Chris _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails