Hello, i''m new in ruby rails framework. I have the following problem. I try to create a scaffold for a certain model of my db, but since ruby rails doesn''t assume the table name corectly (its incidents_reported ) i get errors .... Besides renaming the table :) is there a way to ''tell'' ruby rails the name of the table? I haven''t been able to find any info on this. Thank you in advance.
Hey Kostas, I think this will help you :) http://wiki.rubyonrails.com/rails/pages/HowToUseLegacySchemas Basically, you use: class Entity < ActiveRecord::Base set_table_name "entity" end Brian -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Kostas Katsamakas Sent: Thursday, March 09, 2006 9:39 AM To: rails@lists.rubyonrails.org Subject: [Rails] Problem with scaffolding and table name Hello, i''m new in ruby rails framework. I have the following problem. I try to create a scaffold for a certain model of my db, but since ruby rails doesn''t assume the table name corectly (its incidents_reported ) i get errors .... Besides renaming the table :) is there a way to ''tell'' ruby rails the name of the table? I haven''t been able to find any info on this. Thank you in advance. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
The problem is still that since scaffolding script fails, no rhtml templates are being produced. Brian Corrigan wrote:> Hey Kostas, > > I think this will help you :) > > http://wiki.rubyonrails.com/rails/pages/HowToUseLegacySchemas > > Basically, you use: > class Entity < ActiveRecord::Base > set_table_name "entity" > end > > Brian > > -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Kostas > Katsamakas > Sent: Thursday, March 09, 2006 9:39 AM > To: rails@lists.rubyonrails.org > Subject: [Rails] Problem with scaffolding and table name > > Hello, i''m new in ruby rails framework. I have the following problem. I > try to create a scaffold > for a certain model of my db, but since ruby rails doesn''t assume the > table name corectly (its incidents_reported ) > i get errors .... > > Besides renaming the table :) is there a way to ''tell'' ruby rails the > name of the table? > I haven''t been able to find any info on this. > > Thank you in advance. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 3/10/06, Kostas Katsamakas <kmak@ccf.auth.gr> wrote:> The problem is still that since scaffolding script fails, no rhtml > templates are being produced.So, what are the error messages then? -- ---------------------------------------------------- http://sobrerailes.com
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:> On 3/10/06, Kostas Katsamakas <kmak@ccf.auth.gr> wrote: > >> The problem is still that since scaffolding script fails, no rhtml >> templates are being produced. >> > > So, what are the error messages then? > > -- > ---------------------------------------------------- > http://sobrerailes.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Fri, Mar 10, 2006 at 01:22:13PM +0200, Kostas Katsamakas 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
Agnieszka Figiel
2006-Mar-10 14:11 UTC
[Rails] Re: Problem with scaffolding and table name
Kostas Katsamakas 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 Figiel -- Posted via http://www.ruby-forum.com/.
Thanks a lot. It worked smoothly :) Gregory Seidman wrote:> On Fri, Mar 10, 2006 at 01:22:13PM +0200, Kostas Katsamakas 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 > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Kostas Katsamakas 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---