both will do the same in this case; you could swap the colons and quotes and everything would still be merry. The quotes define a string, the colon define the variable as a symbol. Symbols are a way to store a string only one time; that is, you can save memory by using symbols for strings which are used many times in your app. One restriction is, you cannot modify a symbol like you would modify a string. But for things like method names (like the checkout and empty_cart ones in your example), they are great.
hope it helps, Maximiliano 7, 2009 at 9:30 PM, AlwaysCharging <[email protected]> wrote: > > I'm programming my way through the Agile Web dev book (3rd) and > there's a part in there that's causing a bit of confusion (p. 146 to > be exact). > > You're creating a button in a partial (named _cart.html.erb) using the > following code: > > <%= button_to "Checkout" , :action => 'checkout' %> > > However, earlier in the book, we created a button to empty the cart > by: > > <%= button_to "Empty cart" , :action => :empty_cart %> > > both are pointing to actions defined in the store_controller.rb. > Everything's the same except that checkout is in single quotes and > empty_cart is preceded by a colon. Why is this? > > Is it that 'checkout' is passed a variable where empty_cart is not? > Or, am I having bigger brain fart than that? > > Thank you in advance. > > > --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

