i know this may be easy, but i cant find how to do this. i have a table called status_def i want to generate a scaffold for it, but it will not let me create one because (i think) the table name is not plural. is there a command line option to script/generate that will allow me to create a scaffold if the table is not plural ? btw - all my other tables obey conventions nice, but too much code will have to be re-written to change the name of this table. next question. one of the fields in the status_def table is oem. if i generate a scaffold for this table, can i put something in the model that will only allow records of oem = ''somecompany'' to be selected ? thanks for any tips --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 9, 5:28 am, "nephish" <neph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i know this may be easy, but i cant find how to do this. > > i have a table called status_def > i want to generate a scaffold for it, but it will not let me create > one because (i think) the table name is not plural. > > is there a command line option to script/generate that will allow me > to create a scaffold if the table is not plural ? > > btw - all my other tables obey conventions nice, but too much code > will have to be re-written to change the name of this table. > > next question. > one of the fields in the status_def table is oem. if i generate a > scaffold for this table, can i put something in the model that will > only allow records of oem = ''somecompany'' to be selected ? > > thanks for any tipsI think this is not really a problem with the scaffold but the model, which will be pluralised by default. Once you have generated your scaffold, edit the /app/models/ status_def.rb file to : class StatusDef< ActiveRecord::Base set_table_name "status_def" end I don''t know the answer to your second question, but it implies there is a related company. If this is the case you could use the ID of the company when selecting from status_def. Maybe use act_as_list, or scope would be useful here? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 8, 7:24 pm, "askegg" <andrew.sk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Feb 9, 5:28 am, "nephish" <neph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > i know this may be easy, but i cant find how to do this. > > > i have a table called status_def > > i want to generate a scaffold for it, but it will not let me create > > one because (i think) the table name is not plural. > > > is there a command line option to script/generate that will allow me > > to create a scaffold if the table is not plural ? > > > btw - all my other tables obey conventions nice, but too much code > > will have to be re-written to change the name of this table. > > > next question. > > one of the fields in the status_def table is oem. if i generate a > > scaffold for this table, can i put something in the model that will > > only allow records of oem = ''somecompany'' to be selected ? > > > thanks for any tips > > I think this is not really a problem with the scaffold but the model, > which will be pluralised by default. > > Once you have generated your scaffold, edit the /app/models/ > status_def.rb file to : > > class StatusDef< ActiveRecord::Base > set_table_name "status_def" > end > > I don''t know the answer to your second question, but it implies there > is a related company. If this is the case you could use the ID of the > company when selecting from status_def. Maybe use act_as_list, or > scope would be useful here?ok, well the reason i asked was because when i did the script/generate scaffold status_def it spit out this Before updating scaffolding from new DB schema, try creating a table for your model (StatusDef) and i do have the table in the database . weird. thanks, i found another way around the second question sk --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 9, 3:36 pm, "nephish" <neph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Feb 8, 7:24 pm, "askegg" <andrew.sk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Feb 9, 5:28 am, "nephish" <neph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > i know this may be easy, but i cant find how to do this. > > > > i have a table called status_def > > > i want to generate a scaffold for it, but it will not let me create > > > one because (i think) the table name is not plural. > > > > is there a command line option to script/generate that will allow me > > > to create a scaffold if the table is not plural ? > > > > btw - all my other tables obey conventions nice, but too much code > > > will have to be re-written to change the name of this table. > > > > next question. > > > one of the fields in the status_def table is oem. if i generate a > > > scaffold for this table, can i put something in the model that will > > > only allow records of oem = ''somecompany'' to be selected ? > > > > thanks for any tips > > > I think this is not really a problem with the scaffold but the model, > > which will be pluralised by default. > > > Once you have generated your scaffold, edit the /app/models/ > > status_def.rb file to : > > > class StatusDef< ActiveRecord::Base > > set_table_name "status_def" > > end > > > I don''t know the answer to your second question, but it implies there > > is a related company. If this is the case you could use the ID of the > > company when selecting from status_def. Maybe use act_as_list, or > > scope would be useful here? > > ok, well the reason i asked was because when i did the script/generate > scaffold status_def it spit out this > Before updating scaffolding from new DB schema, try creating a table > for your model (StatusDef) > and i do have the table in the database . > weird. > > thanks, i found another way around the second question > skAhh, opps, yes. The scaffold it built from the model, which is in that naming format. I know the capitals are a requirement of Ruby, but I am not sure about the removal of underscores - probably convention again :) Rails will pluralise the model name to guess the table name, so: ./script/generate scaffold status_def model = StatusDef DB table = statusdefs <- wrong in this case. There does not seem to be a switch on generate to override this behaviour, so you need to do it in three steps (punishment for going outside the conventions) : ./script/generate model status_def model = StatusDef Edit the /app/models/status_def.rb file, add: set_table_name "status_def" ./script/generate scaffold status_def --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 8, 11:09 pm, "askegg" <andrew.sk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Feb 9, 3:36 pm, "nephish" <neph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Feb 8, 7:24 pm, "askegg" <andrew.sk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Feb 9, 5:28 am, "nephish" <neph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > i know this may be easy, but i cant find how to do this. > > > > > i have a table called status_def > > > > i want to generate a scaffold for it, but it will not let me create > > > > one because (i think) the table name is not plural. > > > > > is there a command line option to script/generate that will allow me > > > > to create a scaffold if the table is not plural ? > > > > > btw - all my other tables obey conventions nice, but too much code > > > > will have to be re-written to change the name of this table. > > > > > next question. > > > > one of the fields in the status_def table is oem. if i generate a > > > > scaffold for this table, can i put something in the model that will > > > > only allow records of oem = ''somecompany'' to be selected ? > > > > > thanks for any tips > > > > I think this is not really a problem with the scaffold but the model, > > > which will be pluralised by default. > > > > Once you have generated your scaffold, edit the /app/models/ > > > status_def.rb file to : > > > > class StatusDef< ActiveRecord::Base > > > set_table_name "status_def" > > > end > > > > I don''t know the answer to your second question, but it implies there > > > is a related company. If this is the case you could use the ID of the > > > company when selecting from status_def. Maybe use act_as_list, or > > > scope would be useful here? > > > ok, well the reason i asked was because when i did the script/generate > > scaffold status_def it spit out this > > Before updating scaffolding from new DB schema, try creating a table > > for your model (StatusDef) > > and i do have the table in the database . > > weird. > > > thanks, i found another way around the second question > > sk > > Ahh, opps, yes. The scaffold it built from the model, which is in > that naming format. > I know the capitals are a requirement of Ruby, but I am not sure about > the removal of underscores - probably convention again :) > > Rails will pluralise the model name to guess the table name, so: > > ./script/generate scaffold status_def > model = StatusDef > DB table = statusdefs <- wrong in this case. > > There does not seem to be a switch on generate to override this > behaviour, so you need to do it in three steps (punishment for going > outside the conventions) : > > ./script/generate model status_def > model = StatusDef > > Edit the /app/models/status_def.rb file, add: > set_table_name "status_def" > > ./script/generate scaffold status_defthanks for the help, this table stands alone, no has_many, has_one, hmbtm, etc... just all alone and a scaffold does all the CRUD i need. i appreciate your help. Really, i was good on the other tables, really i was, i even have the book ! don''t know what i was thinking still, but i am all up and running now. thanks again --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---