How to run `rails generate scaffold` when the model already exists? -
i'm new rails current project in weird state.
one of first things generated "movie" model. started defining in more detail, added few methods, etc.
i realize should have generated rails generate scaffold
hook things routing, views, controller, etc.
i tried generate scaffolding got error saying migration file same name exists.
what's best way me create scaffolding "movie" now? (using rails 3)
tl;dr: rails g scaffold_controller <name>
even though have model, can still generate necessary controller , migration files using rails generate
option. if run rails generate -h
can see of options available you.
rails: controller generator helper integration_test mailer migration model observer performance_test plugin resource scaffold scaffold_controller session_migration stylesheets
if you'd generate controller scaffold model, see scaffold_controller
. clarity, here's description on that:
stubs out scaffolded controller , views. pass model name, either camelcased or under_scored, , list of views arguments. controller name retrieved pluralized version of model name.
to create controller within module, specify model name path 'parent_module/controller_name'.
this generates controller class in app/controllers , invokes helper, template engine , test framework generators.
to create resource, you'd use resource
generator, , create migration, can see migration
generator (see, there's pattern of madness). these provide options create missing files build resource. alternatively can run rails generate scaffold
--skip
option skip files exist :)
i recommend spending time looking @ options inside of generators. they're don't feel documented extremely in books , such, they're handy.
Comments
Post a Comment