First, let me say that I’m actually enjoying Ruby on Rails quite a bit. I agree with the large number of people who, like me, are finding that Rails hits a sweet spot between too much structure, configuration and overhead, and anarchy, on the other side. It’s good code, fun to use, and for the most part I enjoy Ruby as a language.
However, being a bit of a perfectionist, and since Rails is “opinionated software”, I thought I’d fire mine right back at it regarding a few of the things I don’t like. Mostly minor nitpicks, but I’ll likely add to them as time goes by and I use Rails more (I’d like to use it more at work, for instance) – after all, I’m opinionated myself.
-
XML processing directives are <? and ?>, not <% and %>. I think PHP got it right there.
-
To make a variable “visible” in a template that you create in a controller, you use an @instance @variable. However, only instance variables are visible in templates, class variables (@@somevar) aren’t. Odd… If I understand things correctly, it turns out that the variable scope isn’t what’s being looked at (as one’s mental model might lead one to believe), but rather, all the instance variables are introspected and made visible in the template. I think I was happier thinking something along the lines of the template having the scope of another method in the controller. I honestly haven’t thought it through, much, but it seems that rather than ‘instance variables’, they are ‘variables marked, via a @, for inclusion in the template’.
-
The one thing that does drive me batty is that you have to restart Webrick to see changes in templates. Other people don’t seem to observe this, so perhaps it’s the versions of everything I’m running (Debian stable, Ruby 1.8.2, Rails 1.0, Postgresql backend) that don’t quite work out. Of course it’s not in production mode and thus cacheing. What happens is when I restart the server, I see the changes I made. At that point, I can usually change the template file once and see the changes. After that, they simply don’t show up, even if changes in the controller always do. So to edit my template, I have to restart the server a bunch, which is extremely annoying. I have a feeling that there must be something I’m doing wrong.
-
I really wish I could use ActiveRecord with primary keys on multiple columns. I know that the authors just aren’t in favor of the idea, but it would be damn useful in transitioning away from legacy databases (I’m thinking of work, here). It would make my life that much better if I could smear some ActiveRecord putty over the crufty old tables and be able to deal with them in a nice, clean way from Ruby.
-
Indiscriminate use of strings and symbols. There doesn’t seem to be an entirely clear rule of when to use strings and when to use symbols. You eventually memorize what to use where, but it feels like it’s not quite as consistent as it might be, that there’s a ‘helpful rule’ that’s missing.
You should use symbols whenever you would use a string except that you wouldn’t want the string’s value to change. The most common usage of this is in hash objects/parameter lists. :some_symbol _will_ _not_ ever change. It’s a reference to a piece of memory. “some string” could very well change. In the cases of parameters and hashes you end up with more trouble than you would otherwise when a string gets changed on its way down. Strings are mutable, and symbols are immutable.
See Also: http://stackoverflow.com/questions/16621073/when-to-use-symbols-versus-strings-in-ruby for a lot more detail.