Forum: Ruby on Rails RE: Problem with scaffolding and table name

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Brian C. (Guest)
on 2006-03-09 17:45
(Received via mailing list)
Hey Kostas,

I think this will help you :)

http://wiki.rubyonrails.com/rails/pages/HowToUseLe...

Basically, you use:
class Entity < ActiveRecord::Base
  set_table_name "entity"
end

Brian
Kostas K. (Guest)
on 2006-03-10 12:18
(Received via mailing list)
The problem is still that since scaffolding script fails, no rhtml
templates are being produced.
Juan Lupión (Guest)
on 2006-03-10 12:30
(Received via mailing list)
On 3/10/06, Kostas K. <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?

--
Kostas K. (Guest)
on 2006-03-10 14:41
(Received via mailing list)
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:
Agnieszka F. (Guest)
on 2006-03-10 16:11
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.
Gregory S. (Guest)
on 2006-08-03 16:21
(Received via mailing list)
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
Kostas K. (Guest)
on 2006-08-03 16:22
(Received via mailing list)
Thanks a lot. It worked smoothly :)
Le H. (Guest)
on 2006-12-04 07:08
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
This topic is locked and can not be replied to.