Skip to content

Instantly share code, notes, and snippets.

@JackBracken
Created February 3, 2016 17:22
Show Gist options
  • Save JackBracken/6cddcebc53b0a5a2b5cb to your computer and use it in GitHub Desktop.
Save JackBracken/6cddcebc53b0a5a2b5cb to your computer and use it in GitHub Desktop.
class CreateSomeModel < ActiveRecord::Migration
create_table :some_model do |t|
# SomeModel :active should always default to false
t.boolean :active, null: false, default: false
end
end
class SomeModel < ActiveRecord::Base
# But Model scope will override it
default_scope{ where(active: true) }
end
# sm = SomeModel.create()
# => #<SomeModel id: 1, active: true>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment