R
Robert Eisig
Hi,
in rails I have to use an existing mysql table named "my_choice". It
does not follow the convention of tables being named plural.
To be able to use the "generate model" script I changed the following
in the file inflections.rb in the active_support lib (almost at the end
of the file):
inflect.uncountable(%w(equipment information [...] sheep my_choice))
I just added the table name at the end. After running the
"script/generate model my_choice" I removed it again.
(This resulted in correctly created files in test and db/migrate)
And then I added a line in the model that was just created:
class MyChoice < ActiveRecord::Base
set_table_name "my_choice"
end
Question: is this a good idea and the best possible way? Could I have
problems with this in the future working with it? How can I do this
easier when it happens again... ain't there a paramter for "generate
model" ? Something like "script/generate model --no-inflect my_choice"?
Thank you
Robert
in rails I have to use an existing mysql table named "my_choice". It
does not follow the convention of tables being named plural.
To be able to use the "generate model" script I changed the following
in the file inflections.rb in the active_support lib (almost at the end
of the file):
inflect.uncountable(%w(equipment information [...] sheep my_choice))
I just added the table name at the end. After running the
"script/generate model my_choice" I removed it again.
(This resulted in correctly created files in test and db/migrate)
And then I added a line in the model that was just created:
class MyChoice < ActiveRecord::Base
set_table_name "my_choice"
end
Question: is this a good idea and the best possible way? Could I have
problems with this in the future working with it? How can I do this
easier when it happens again... ain't there a paramter for "generate
model" ? Something like "script/generate model --no-inflect my_choice"?
Thank you
Robert