SitePoint Sponsor |
|
User Tag List
Results 1 to 13 of 13
-
Nov 8, 2005, 13:30 #1
- 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?
-
Nov 8, 2005, 13:56 #2
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.
-
Nov 8, 2005, 14:34 #3
- Join Date
- Sep 2005
- Posts
- 6
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by vgarcia
-
Nov 9, 2005, 23:27 #4
- 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.
-
Nov 10, 2005, 08:45 #5
- 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.
-
Nov 11, 2005, 18:24 #6
- 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.
-
Nov 12, 2005, 04:14 #7
- 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.
-
Nov 12, 2005, 09:59 #8
- Join Date
- Nov 2001
- Location
- Bath, UK
- Posts
- 2,498
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by ryanyogan
Hello World
-
Nov 12, 2005, 10:01 #9
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by DougBTX
-
Nov 12, 2005, 10:09 #10
- Join Date
- Nov 2001
- Location
- Bath, UK
- Posts
- 2,498
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by xmitchx
DouglasHello World
-
Nov 14, 2005, 10:20 #11
- 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.
-
Nov 14, 2005, 18:44 #12
- 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.
-
Nov 15, 2005, 19:27 #13
- 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