SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    1.0 RC4 (0.14.3) - Controller Symbols

    Updated today and I noticed my controller symbols don't seem to be defined anymore. For example I used to be able to do this:

    <%= link_to 'Options', :controller => :option %>

    after the update I must do:

    <%= link_to 'Options', :controller => 'option' %>

    or else I get:

    undefined method `include?' for :option:Symbol

    Anyone else notice this? I didn't see mention in the release notes. Is there a new config setting I missed somewhere?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    What was the old version of Rails you had? I've been using the syntax in your second example since I started serious Rails development (0.12 or so) so I'm not sure when/if it changed.

  3. #3
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    What was the old version of Rails you had? I've been using the syntax in your second example since I started serious Rails development (0.12 or so) so I'm not sure when/if it changed.
    Upgraded from 0.14.2. In the past it worked with string or symbol notation, now the symbols are not defined.

  4. #4
    SitePoint Addict Brak's Avatar
    Join Date
    Jul 2004
    Location
    Central Coast, CA
    Posts
    321
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A lot of 1.0 stuff has been stricter enforcements of methods. I think I remember reading something about it somewhere... oh well, I can't remember right now.
    Studio Rockstar's Blog - A journey to quitting the dayjob.

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right, i remembe reading that in the ActiveRecord::Base::Find method you can no longer have ":condition" it must be ":conditions"

    There are others i believe.

  6. #6
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Yakima WA.
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have been using this method:

    <%= link_to 'Options', :controller => 'option' %>

    Since rails 0.8.5 and have never seen anyone use the other way you posted it. So I am kind of surprised the other way ever worked. Best to just not do that anymore as it is not supported.

  7. #7
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You wouldn't want to use a symbol anyway that is proving nothing there and just a waste of a variable, small one yes I know, but just stick to passing it with two ' ' double qoutes are not needed as there is no formatting needed.

  8. #8
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryanyogan
    You wouldn't want to use a symbol anyway that is proving nothing there and just a waste of a variable, small one yes I know, but just stick to passing it with two ' ' double qoutes are not needed as there is no formatting needed.
    Symbols take up less memory/processing than strings.
    Hello World

  9. #9
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    Symbols take up less memory/processing than strings.
    Symbols become strings in rails. So it doesnt matter.

  10. #10
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by xmitchx
    Symbols become strings in rails. So it doesnt matter.
    Well, not in this case, or the OP wouldn't have started the thread

    Douglas
    Hello World

  11. #11
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Yakima WA.
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Symbols do behave similar to strings in rails thanks to HashWithIndifferentAccess. That is how you can interchange :foo and 'foo' in parts of the different command in rails. So you really don't save enough memory to make the difference worth it at all with rails. Especially with the fact that all variables/symbols are destroyed on every hit to your rails app. The old symbols and strings just kind of go into purgatory waiting to be reaped by the Garbage Collector.

  12. #12
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are right about them taking up less memory, I guess it is just good practice to generally use what is necessary. In this case using a simple string with no formatting is what I would do.

  13. #13
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the most important thing is the difference between what they mean, rather than any marginal performance benifits. The symbols are used as keys because their meaning and uniqueness are the most important things about them, whereas strings are used in the values because their content is themost important thing about them.
    Hello World


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •