# Noob ? - Diff Between "action =\> :index" and "action =\> 'index'"?

**URL:** <https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864>\
**Category:** Rails\
**Created:** [April 25, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864 "2008-04-25T19:18:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 25, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864/1 "2008-04-25T19:18:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 25, 2008, 8:19pm UTC](https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864/2 "2008-04-25T20:19:28Z")

</div>

Are there any benefits (from a programming perspective) of using one  
convention over the other?

tnx

On Apr 25, 10:18 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 25, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864/3 "2008-04-25T19:19:29Z")

</div>

On 25 Apr 2008, at 17:48, RoRNoob wrote:

> \<%= 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

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 25, 2008, 10:04pm UTC](https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864/4 "2008-04-25T22:04:45Z")

</div>

Without getting into the details, symbols use less memory.

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 25, 2008, 10:05pm UTC](https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864/5 "2008-04-25T22:05:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 25, 2008, 10:07pm UTC](https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864/6 "2008-04-25T22:07:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 26, 2008, 1:07am UTC](https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864/7 "2008-04-26T01:07:12Z")

</div>

Jason R. 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](http://api.rubyonrails.com/classes/HashWithIndifferentAccess.html)

Rails’ hashes use both.

---

<div class="post-metadata">

**Author:** ![rornoob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@rornoob](https://www.ruby-forum.com/u/rornoob)\
**Post date:** [April 26, 2008, 10:56am UTC](https://www.ruby-forum.com/t/noob-diff-between-action-index-and-action-index/135864/8 "2008-04-26T10:56:20Z")

</div>

On 26 Apr 2008, at 00:07, Daniel W. wrote:

> > 
> 
> 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
