Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### En el terminal agregamos la columna status al modelo
- `✗ rails g migration add_post_status_to_blogs status:integer`
- ### En atom agregamos el default a la definición de la migración y luego `✗ rails db:migrate`
- `add_column :blogs, :status, :integer, default: 0`
- ### Agregamos en blog.rb
- `enum status: {draft: 0, published: 1}`
- ### Si se crea un nuevo registro se verá el contenido mapeado de status que hace enum
- `status: "draft"`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement