[Rails-core] [3795] render_component doesn't work with modules?

Stefan Kaes skaes at gmx.net
Sat Feb 11 08:24:39 GMT 2006


Rick Olson wrote:
> On 2/10/06, Trevor Squires <trevor at protocool.com> wrote:
>   
>> Hi Nathaniel,
>>
>> I'm using a version of edge (not the most recent, but after module
>> namespace support was improved) and I use render_component into a
>> module namespace quite extensively with no problems.
>>
>> I know you said you "nailed it down to having a '/' in the
>> controller" but are you sure it's not simply the *leading* slash
>> character that's giving you problems?
>>
>> Regards,
>> Trevor
>>     
>
> This might be related to changeset [3563]
> (http://dev.rubyonrails.org/changeset/3563).  When I get some time
> I'll dig into the issue if no one else has by then.
>
> --
> Rick Olson
> http://techno-weenie.net
> _______________________________________________
> Rails-core mailing list
> Rails-core at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-core
>
>
>   
This is a bug in the constantize implementation. I suggest to change it 
to the following code, which apart from fixing the bug, is a faster as well:

  def constantize(camel_cased_word)
    begin
      if camel_cased_word[0, 2] == '::'
        Object.module_eval(camel_cased_word, __FILE__, __LINE__)
      else
        Object.module_eval("::#{camel_cased_word}", __FILE__, __LINE__)
      end
    rescue NameError, SyntaxError
      raise NameError, "#{camel_cased_word.inspect} is not a valid 
constant name!"
    end
  end

See ticket http://dev.rubyonrails.org/ticket/3803

-- stefan

-- 
For rails performance tuning, see: http://railsexpress.de/blog
Subscription: http://railsexpress.de/blog/xml/rss20/feed.xml



More information about the Rails-core mailing list