RoRNoob
2008-Apr-25 16:48 UTC
Noob ? - Diff Between "action => :index" and "action => ''index''" ?
What is the difference between specifiying a link_to action with a ":" vs. "''''" ? Example: <%= link_to "Continue your spree", :action => :index %> vs. <%= link_to "Continue your spree", :action => ''index'' %> Is there one? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-25 17:18 UTC
Re: Noob ? - Diff Between "action => :index" and "action => ''index''" ?
On 25 Apr 2008, at 17:48, RoRNoob wrote:> > What is the difference between specifiying a link_to action with a ":" > vs. "''''" ? > > Example: > > <%= link_to "Continue your spree", :action => :index %> > > vs. > > <%= link_to "Continue your spree", :action => ''index'' %> > > Is there one?In one case you''re passing the string ''index'' and in the other case a symbol. rails doesn''t care though. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RoRNoob
2008-Apr-25 18:18 UTC
Re: Noob ? - Diff Between "action => :index" and "action => ''index''" ?
Are there any benefits (from a programming perspective) of using one convention over the other? tnx On Apr 25, 10:18 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 25 Apr 2008, at 17:48,RoRNoobwrote: > > > What is the difference between specifiying a link_to action with a ":" > > vs. "''''" ? > > > Example: > > > <%= link_to "Continue your spree", :action => :index %> > > > vs. > > > <%= link_to "Continue your spree", :action => ''index'' %> > > > Is there one? > > In one case you''re passing the string ''index'' and in the other case a > symbol. rails doesn''t care though. > > Fred--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
AndyV
2008-Apr-25 20:03 UTC
Re: Noob ? - Diff Between "action => :index" and "action => ''index''" ?
Without getting into the details, symbols use less memory. On Apr 25, 2:18 pm, RoRNoob <rorn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are there any benefits (from a programming perspective) of using one > convention over the other? > > tnx > > On Apr 25, 10:18 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On 25 Apr 2008, at 17:48,RoRNoobwrote: > > > > What is the difference between specifiying a link_to action with a ":" > > > vs. "''''" ? > > > > Example: > > > > <%= link_to "Continue your spree", :action => :index %> > > > > vs. > > > > <%= link_to "Continue your spree", :action => ''index'' %> > > > > Is there one? > > > In one case you''re passing the string ''index'' and in the other case a > > symbol. rails doesn''t care though. > > > Fred--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-25 20:05 UTC
Re: Noob ? - Diff Between "action => :index" and "action => ''index''" ?
On 25 Apr 2008, at 21:03, AndyV wrote:> > Without getting into the details, symbols use less memory. >On the other hand they can''t be garbage collected. In practical terms, I don''t think it makes much difference either way. Fred> On Apr 25, 2:18 pm, RoRNoob <rorn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Are there any benefits (from a programming perspective) of using one >> convention over the other? >> >> tnx >> >> On Apr 25, 10:18 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> >>> On 25 Apr 2008, at 17:48,RoRNoobwrote: >> >>>> What is the difference between specifiying a link_to action with >>>> a ":" >>>> vs. "''''" ? >> >>>> Example: >> >>>> <%= link_to "Continue your spree", :action => :index %> >> >>>> vs. >> >>>> <%= link_to "Continue your spree", :action => ''index'' %> >> >>>> Is there one? >> >>> In one case you''re passing the string ''index'' and in the other >>> case a >>> symbol. rails doesn''t care though. >> >>> Fred > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2008-Apr-25 20:07 UTC
Re: Noob ? - Diff Between "action => :index" and "action => ''index''" ?
But symbols never get GC''d. So use enough symbols, and you permanently use more memory. My rule of thumb for symbol use: - hash keys - config specifications (has_many :my_things) - State designators (:open, :closed) If it''s a name of something , or something that gets displayed to the user, in most cases I''ll use strings. Jason On Fri, Apr 25, 2008 at 4:03 PM, AndyV <AndyVanasse-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Without getting into the details, symbols use less memory. > > > > On Apr 25, 2:18 pm, RoRNoob <rorn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Are there any benefits (from a programming perspective) of using one > > convention over the other? > > > > tnx > > > > On Apr 25, 10:18 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > > On 25 Apr 2008, at 17:48,RoRNoobwrote: > > > > > > What is the difference between specifiying a link_to action with a ":" > > > > vs. "''''" ? > > > > > > Example: > > > > > > <%= link_to "Continue your spree", :action => :index %> > > > > > > vs. > > > > > > <%= link_to "Continue your spree", :action => ''index'' %> > > > > > > Is there one? > > > > > In one case you''re passing the string ''index'' and in the other case a > > > symbol. rails doesn''t care though. > > > > > Fred > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daniel Waite
2008-Apr-25 23:07 UTC
Re: Noob ? - Diff Between "action => :index" and "action =>
Jason Roelofs wrote:> But symbols never get GC''d. So use enough symbols, and you permanently > use more memory. > > My rule of thumb for symbol use: > - hash keys > - config specifications (has_many :my_things) > - State designators (:open, :closed) > > If it''s a name of something , or something that gets displayed to the > user, in most cases I''ll use strings. > > JasonThe memory argument is moot in Rails as it uses both. See HashWithIndifferentAccess: http://api.rubyonrails.com/classes/HashWithIndifferentAccess.html Rails'' hashes use both. -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-26 08:55 UTC
Re: Noob ? - Diff Between "action => :index" and "action =>
On 26 Apr 2008, at 00:07, Daniel Waite wrote:> > Jason Roelofs wrote: >> But symbols never get GC''d. So use enough symbols, and you >> permanently >> use more memory. >> >> My rule of thumb for symbol use: >> - hash keys >> - config specifications (has_many :my_things) >> - State designators (:open, :closed) >> >> If it''s a name of something , or something that gets displayed to the >> user, in most cases I''ll use strings. >> >> Jason > > The memory argument is moot in Rails as it uses both. > > See HashWithIndifferentAccess: > http://api.rubyonrails.com/classes/HashWithIndifferentAccess.html > > Rails'' hashes use both.Nearly nothing uses HashWithIndifferentAccess, (only the params hash I think). Deep down on the inside, it''s a hash with string keys, but if you give it a symbol key it will convert that to a string first (and some other niceties related to that). Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---