Adam Perfect

General

One flaw of Rails

... is that it's only relatively recently become popular so it can be hard finding advice on problems when programming. I've come across a couple of issues so far where I've posted on forums and it's taken a day or two before you get any kind of response and a couple of times there just plain hasn't been a response. I think Ruby developers seem to gravitate more towards mailing lists however, so I may have to try using one of them instead. I'm currently having trouble with the following issue. If you know of a solution, PLEASE let me know. Otherwise, if I ever find a solution I'll try to post here for others' reference.

  • Dynamic class names
    • I've found the answer to the first part of this (i.e. being able to instantiate a class where the class name is variable), you use:
      • foo = object.const_get("class_name").new
    • The second part is a problem caused by Rails controller 'modules' - i.e. where you have SomeName::SomeController which isn't a constant. I thought I'd found the answer when I found this mention on Ruby Weekly News of a method class_name.constantize but I now get this error:
      • Manage::UsersController is not a symbol
    • Full description of the problem with code

Written by Adam on

Adam is a Director of User Experience by day and photographer as time allows.

You may also like…