This file contains hidden or 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
| <div class="source-fields"> | |
| <%= text_field_tag 'post[sources][]', source %> | |
| <%= link_to '#', class: 'remove-section', data: { target: '.source-fields' } do %> | |
| Remove | |
| <% end %> | |
| </div> |
This file contains hidden or 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
| post[sources][]: "https://one.example.com" | |
| post[sources][]: "https://two.example.com" |
This file contains hidden or 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
| <div class="field"> | |
| <%= f.label :body %> | |
| <%= f.text_area :body, size: '100x10' %> | |
| </div> |
This file contains hidden or 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
| irb> post = Post.new | |
| => #<Post id: nil, title: nil, content: {"sources"=>[]}, created_at: nil, updated_at: nil, body: nil, sources: []> | |
| irb> post.body | |
| => nil | |
| irb> post.sources | |
| => [] |
This file contains hidden or 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
| jsonb_accessor :content, | |
| body: :string, | |
| sources: [:JSON, array: true, default: []] |
This file contains hidden or 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
| rails generate model Post title:string content:JSONB |
This file contains hidden or 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
| /* | |
| * FUNCTION CALLBACK WAY | |
| */ | |
| connection.query({ | |
| sql : "SELECT * FROM Queue WHERE id = ? AND deleted_at IS NULL", | |
| values : [req.params.queueId], | |
| }, function (err, results, fields) { | |
| if (err) { | |
| // TODO error logging | |
| console.log(err); |
This file contains hidden or 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
| /* | |
| * FIRST WAY | |
| */ | |
| var queue; | |
| connection2.query( | |
| 'SELECT * FROM Queue WHERE id = ? AND deleted_at IS NULL', | |
| [req.params.queueId] | |
| ).then(results => { | |
| queue = results[0]; | |
| // if queue exists, delete it |
This file contains hidden or 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
| for(int i = 0, total = 0, max = 55; i <= max + 1; total += i, i++) if (i == max + 1) System.out.println(total); |
This file contains hidden or 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
| int max = 55; | |
| int total = 0; | |
| for(int i = 0; i <= max; i++) | |
| total += i; | |
| System.out.println(total); |
NewerOlder