-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JSON attributes default documentation/UTs
Unit tests and documentation have been added, explaining the proper way to set a default. The alternative implementation is also explained. Closes #4.
- Loading branch information
1 parent
9fb58f6
commit 5212dff
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
ActiveRecord::Schema.define(version: 20180210000000) do | ||
ActiveRecord::Schema.define(version: 20180214000000) do | ||
create_table "users" do |t| | ||
t.json "extras" | ||
end | ||
|
||
create_table "with_default_users" do |t| | ||
t.json "extras" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class WithDefaultUser < ActiveRecord::Base | ||
after_initialize do |instance| | ||
instance.extras = {} | ||
end | ||
end |