# RE: Problem with scaffolding and table name

**URL:** <https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032>\
**Category:** Rails\
**Created:** [March 9, 2006, 4:45pm UTC](https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032 "2006-03-09T16:45:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [March 9, 2006, 4:45pm UTC](https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032/1 "2006-03-09T16:45:11Z")

</div>

Hey Kostas,

I think this will help you 🙂

[http://wiki.rubyonrails.com/rails/pages/HowToUseLegacySchemas](http://wiki.rubyonrails.com/rails/pages/HowToUseLegacySchemas)

Basically, you use:  
class Entity \< ActiveRecord::Base  
set\_table\_name “entity”  
end

Brian

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [March 10, 2006, 11:18am UTC](https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032/2 "2006-03-10T11:18:29Z")

</div>

The problem is still that since scaffolding script fails, no rhtml  
templates are being produced.

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [March 10, 2006, 11:30am UTC](https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032/3 "2006-03-10T11:30:33Z")

</div>

On 3/10/06, Kostas K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The problem is still that since scaffolding script fails, no rhtml  
> templates are being produced.

So, what are the error messages then?

–

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [March 10, 2006, 3:11pm UTC](https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032/4 "2006-03-10T15:11:04Z")

</div>

Kostas K. wrote:

> scripts/generate scaffold incident\_reported
> 
> ----\> error Before updating scaffolding from new DB schema, try  
> creating a table for your model (IncidentReported)
> 
> I think it has to do with rails assuming the table is named  
> ‘incident\_reporteds’ which is wrong.  
> I was asking how i could inform rails’ scaffolding operation that my  
> table is named ‘incidents\_reported’
> 
> Juan Lupiï¿½n wrote:

if it is really so, it should help to set the table name in the  
IncidentReported model:  
set\_table\_name “incidents\_reported”

–  
Agnieszka F.

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [March 10, 2006, 1:41pm UTC](https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032/5 "2006-03-10T13:41:18Z")

</div>

scripts/generate scaffold incident\_reported

----\> error Before updating scaffolding from new DB schema, try  
creating a table for your model (IncidentReported)

I think it has to do with rails assuming the table is named  
‘incident\_reporteds’ which is wrong.  
I was asking how i could inform rails’ scaffolding operation that my  
table is named ‘incidents\_reported’

Juan Lupión wrote:

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [August 3, 2006, 2:21pm UTC](https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032/6 "2006-08-03T14:21:56Z")

</div>

On Fri, Mar 10, 2006 at 01:22:13PM +0200, Kostas K. wrote:  
} scripts/generate scaffold incident\_reported  
}  
} ----\> error Before updating scaffolding from new DB schema, try  
} creating a table for your model (IncidentReported)  
}  
} I think it has to do with rails assuming the table is named  
} ‘incident\_reporteds’ which is wrong.  
} I was asking how i could inform rails’ scaffolding operation that my  
} table is named ‘incidents\_reported’

Toward the end of your config/environment.rb there should be a commented  
out section on inflections. You want something like this:

Inflector.inflections do |inflect|  
inflect.irregular ‘incident\_reported’, ‘incidents\_reported’  
end

–Greg

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [August 3, 2006, 2:22pm UTC](https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032/7 "2006-08-03T14:22:24Z")

</div>

Thanks a lot. It worked smoothly 🙂

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [December 4, 2006, 6:08am UTC](https://www.ruby-forum.com/t/re-problem-with-scaffolding-and-table-name/79032/8 "2006-12-04T06:08:31Z")

</div>

Kostas K. wrote:

> Thanks a lot. It worked smoothly 🙂

I have same problem with legacy table name and can not figure out how to  
make scaffold work

e.g

I have table name ‘ACTIVETASK’ and model ActiveTask

require ‘composite\_primary\_keys’  
class ActiveTask \< ActiveRecord::Base  
set\_table\_name :ACTIVETASK  
set\_primary\_keys :id, :site\_id  
end

my config/environment.rb  
…

Inflector.inflections do |inflect|  
inflect.irregular ‘ActiveTask’, ‘activetask’  
inflect.uncountable ‘ActiveTask’  
end
