# Very weird - Type error where there isn't one?!

**URL:** <https://www.ruby-forum.com/t/very-weird-type-error-where-there-isnt-one/120941>\
**Category:** Rails\
**Created:** [November 22, 2007, 12:10am UTC](https://www.ruby-forum.com/t/very-weird-type-error-where-there-isnt-one/120941 "2007-11-22T00:10:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [November 22, 2007, 12:10am UTC](https://www.ruby-forum.com/t/very-weird-type-error-where-there-isnt-one/120941/1 "2007-11-22T00:10:28Z")

</div>

Hi all

Put the following code in a view of a Rails app (replace the model  
classes in the array with some of your model classes):

```
<ul class="buttons">
  <% [Country, LinkCategory, Link, Member, MusicArtist, MusicLabel,

```

MusicStyle, PartySetting, PsyCommunity, OnlineShop, Session,  
SystemGroup, SystemRight].each do |clazz| %\>  
\<%= “\<li” + (’ class=“selected”’ if clazz.to\_s.pluralize +  
“Controller” == self.controller.class.to\_s) + “\>” +  
clazz.to\_s.tableize.titleize + “” if user\_authorized\_to?(‘VIEW’,  
clazz) %\>  
\<% end %\>

You’ll be surprised - you’ll get a TypeError. Now re-arrange the code to  
the following:

```
<ul class="buttons">
  <% [Country, LinkCategory, Link, Member, MusicArtist, MusicLabel,

```

MusicStyle, PartySetting, PsyCommunity, OnlineShop, Session,  
SystemGroup, SystemRight].each do |clazz| %\>  
\<%= “\<li” + (’ class=“selected”’ if true) + “\>” +  
clazz.to\_s.tableize.titleize + " #{clazz.to\_s.pluralize + “Controller”  
== self.controller.class.to\_s}" if user\_authorized\_to?(‘VIEW’,  
clazz) %\>  
\<% end %\>

Now it works! Same code fragments, but different effect! What’s wrong  
here?! Very annoying…

Thanks,  
Josh
