I'm working with RoR with a legacy database in spanish language.
I have the table and registropersona
and model RegistroPersona
. Now I want to run rails generate scaffold_controller registro_persona
But the generated name of controller should be
RegistrosPersonasController
(Note the final s in Registros and Personas).
How can I do this?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Strong parameter override for DeviseTokenAuth cont
- Mechanize getting “Errno::ECONNRESET: Connection r
- Eager-loading association count with Arel (Rails 3
相关文章
- Right way to deploy Rails + Puma + Postgres app to
- AWS S3 in rails - how to set the s3_signature_vers
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
- “No explicit conversion of Symbol into String” for
- form_for wrong number of arguments in rails 4
- Rspec controller error expecting <“index”> but
- Factory_girl has_one relation with validates_prese
Unfortunately, I don't think there is a way to specify the controller name using
scaffold_controller
without also affecting the model name. I've looked around and haven't been able to find anything that does what you're looking for.I believe you have two options:
1 - use
rails generate controller RegistrosPersonas
. The downside is you end up with a blank controller, and you'd have to fill in all of the REST methods yourself.2 - use
rails generate scaffold_controller RegistrosPersonas
. This will create the REST methods for you, however all of the model references will use the pluralized name (ie you'll seeRegistrosPersonas.all
). So the downside is that you'll need to go through the controller and change each reference fromRegistrosPersonas
toRegistroPersona
. Hopefully you should simply be able to use a simple find + replace in whatever text editor or IDE you're using.Hope that helps somewhat.
You can either edit your
config/initializers/infletions.rb
file to support that, or just rename the controller manually.