"The name 'Friendship' is reserved by Ruby on Rails." messag


#1

Hi,

I am new to Rails. I am using Rails 1.8.5 on win xp. When I try to
generate scaffold, using

ruby script/generate scaffold Friendship

I got the message:

“…
dependency model
The name ‘Friendship’ is reserved by Ruby on Rails.
Please choose an alternative and run this generator again.”

If I try to do

ruby script/generate scaffold comment

it then say: “The name ‘CommentsController’ is reserved by Ruby on
Rails.”

What could be wrong? Can anyone explain what’s happening here?

Thanks,

Victor


#2

I could not reproduce the Friendship error on my machine. However, I
was able to get the same message by trying the generate a resource
called ActiveRecord. The message comes from raise_class_collision in
commands.rb:

def raise_class_collision(class_name)
message = <<end_message
The name ‘#{class_name}’ is reserved by Ruby on Rails.
Please choose an alternative and run this generator again.
end_message

This only gets called from one place, class_collisions in the same
file:

If the last Module exists, check whether the given

class exists and raise a collision if so.

if last and last.const_defined?(name.camelize)
raise_class_collision(class_name)
end

So somewhere you have a class/module named Friendship already loaded
when the generator runs. This could be from a plugin, gem, lib class,
etc… you have loaded. The “reserved by Ruby on Rails” is a bit
misleading. It could be from Rails, but it also could be from a
number of other places.

Aaron