Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an option to generate scaffolding without generating migrations?

One of the things that bothers me in Rails is that scaffolding generates migrations that I don't always need.

Is there a way to generate the scaffold without the corresponding migration?

like image 218
eggdrop Avatar asked May 25 '09 16:05

eggdrop


People also ask

How do you generate scaffold in Rails?

To generate a fully working scaffold for a new object, including model, controller, views, assets, and tests, use the rails g scaffold command. Then you can run rake db:migrate to set up the database table. Then you can visit http://localhost:3000/widgets and you'll see a fully functional CRUD scaffold.

Why do we need migration in Rails?

Rails Migration allows you to use Ruby to define changes to your database schema, making it possible to use a version control system to keep things synchronized with the actual code. Teams of developers − If one person makes a schema change, the other developers just need to update, and run "rake migrate".

How does Rails keep track of migrations?

Every time a migration is generated using the rails g migration command, Rails generates the migration file with a unique timestamp. The timestamp is in the format YYYYMMDDHHMMSS . Whenever a migration is run, Rails inserts the migration timestamp into an internal table schema_migrations .

What is Ruby migration?

Migrations are a convenient way to alter your database schema over time in a consistent way. They use a Ruby DSL so that you don't have to write SQL by hand, allowing your schema and changes to be database independent. You can think of each migration as being a new 'version' of the database.


1 Answers

Use the --skip-migration parameter. For example:

rails generate scaffold post title:string body:text --skip-migration 
like image 181
Tim Sullivan Avatar answered Oct 22 '22 14:10

Tim Sullivan