Error generating any scaffold

I have a problem with one Rails project and I can’t figure out why. I
get the following error when any scaffold is generated:

The name ‘[model_name]’ is reserved by Ruby on Rails.

So basically Rails complains that any model name I use is a reserved
word. My model names are User, Invoice, InvoiceLineItem, Service and
more…they aren’t reserved words.

The only significant difference between this project and the other is
the version of rails. This project is on edge.

Has anyone had this happen before?

I just thought to run a trace and found our there is a class collision
happening when generating a scaffold. Why would there be a class
collision?

I also found scaffolds can be generated for very simple models. However
virtually any model that has a belongs_to relationship can’t have a
scaffold generated.

Just to simplyfy things I commented out all relationships from the
models, but the scaffolds still can’t be generated. I think this happens
because rails is actually looking at my database and not the model when
generating the scaffold (how else would it kno whot to bind the HTML
inputs?), and it spots “forgeign key” fields and chokes. Is this true?

I’m new to rails and not sure exactly what I should do. Any suggestions?

I know scaffolds aren’t the be-all-end-all but I was hoping to save some
time by by using them as a starting point. My application is very
CRUD-like and would only need minimal changes.

Ok…just to keep anyone in the same boat updated…I went through and
deleted all foreign key columns in the database. I did this to force a
really simple table/model. Generate scaffold still fails. Rails just
doesn’t want to create scaffolds for the majority of my models.

Just to keep anyone in this same situation updated…

Watch our for Observers and enerate Scaffold. If you have an Observer
attached to any of your Models, Rails will throw a raise a class
collission error if you try and generate a scaffold on that model.

It’s not an obvious error and you’ll spend hours trying to figure out
where the problem is.

Solution: Remove your observer, genrerate the scaffold, add observer
back in.

On 10/3/06, Brandon C. [email protected] wrote:

Solution: Remove your observer, genrerate the scaffold, add observer
back in.

Great catch, Brandon. Would you open a ticket for this issue?
http://dev.rubyonrails.org/newticket

Thanks,
jeremy

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs