Cake views are just presentation-flavored fragments that fit inside
an application’s layout. For most applications they’re HTML mixed
with PHP, but they may end up as XML, CSV, or even binary data.
Layouts are presentation code that is wrapped around a view, and
can be defined and switched between
if the HTTP method of the
request was POST, try to save the data using the Post model.
db:setup task will create the database, load the schema and initialize
it with the seed data
db:reset task will drop the database and set it up again. This is
functionally equivalent to rails db:drop db:setup.
run a specific migration up or down, the db:migrate:up and
db:migrate:down
the
RAILS_ENV environment variable
db:migrate
VERBOSE=false will suppress all output.
If you have
already run the migration, then you cannot just edit the migration and run the
migration again: Rails thinks it has already run the migration and so will do
nothing when you run rails db:migrate.
must rollback the migration (for
example with bin/rails db:rollback), edit your migration and then run
rails db:migrate to run the corrected version.
editing existing migrations is not a good idea.
should write a new migration that performs the changes
you require
revert method can be helpful when writing a new migration to undo
previous migrations in whole or in part
require_relative
revert
They are not designed to be
edited, they just represent the current state of the database.
Schema Files for
Schema files are also useful if you want a quick look at what attributes an
Active Record object has
annotate_models gem automatically
adds and updates comments at the top of each model summarizing the schema if
you desire that functionality.
database-independent
multiple databases
db/schema.rb cannot express database specific
items such as triggers, stored procedures or check constraints
you can execute custom SQL statements, the schema dumper cannot
reconstitute those statements from the database