Skip to content

Commit 79e789b

Browse files
authored
Merge pull request #5 from vfonic/patch-1
Add syntax highlighting for ruby code
2 parents 3d03e69 + 38bbd56 commit 79e789b

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,22 @@ MySQL only supports SQL expression defaults for `TIMESTAMP` column types, which
4343

4444
SchemaPlus::DefaultExpr augments the syntax for setting column defaults, to support expressions or constant values:
4545

46-
t.datetime :seen_at, default: { expr: 'NOW()' }
47-
t.datetime :seen_at, default: { value: "2011-12-11 00:00:00" }
46+
```ruby
47+
t.datetime :seen_at, default: { expr: 'NOW()' }
48+
t.datetime :seen_at, default: { value: "2011-12-11 00:00:00" }
49+
```
4850

4951
The standard syntax will still work as usual:
5052

51-
t.datetime :seen_at, default: "2011-12-11 00:00:00"
53+
```ruby
54+
t.datetime :seen_at, default: "2011-12-11 00:00:00"
55+
```
5256

5357
Also, as a convenience
5458

55-
t.datetime :seen_at, default: :now
59+
```ruby
60+
t.datetime :seen_at, default: :now
61+
```
5662

5763
resolves to:
5864

@@ -64,9 +70,10 @@ resolves to:
6470

6571
If you are using Postgresql with a `json` column, ActiveRecord allows you to use a Hash for a default value. Be aware that if the hash contains just one key which is `:expr` or `:value`, then SchemaPlus::DefaultExpr will interpret, and use the corresponding value for the default. That is, these are equivalent:
6672

67-
t.json :fields, default: { value: { field1: 'a', field2: 'b' } }
68-
t.json :fields, default: { field1: 'a', field2: 'b' }
69-
73+
```ruby
74+
t.json :fields, default: { value: { field1: 'a', field2: 'b' } }
75+
t.json :fields, default: { field1: 'a', field2: 'b' }
76+
```
7077

7178
## History
7279

0 commit comments

Comments
 (0)