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
upstream puma { | |
server unix:///home/user/apps/meudominio/shared/tmp/sockets/certamei-puma.sock; | |
} | |
server { | |
listen 80; | |
server_name meudominio.com.br www.meudominio.com.br; | |
root /var/www/meudominio.com.br/html/; | |
access_log /var/log/nginx/access.log; |
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
Event delegation | |
$(document).on('turbolinks:load',function() { | |
employees_table_list(); | |
}).on('ajax:success', '#employee-form', function(){ | |
employees_table_list(); | |
}); |
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
require 'open-uri' | |
require 'net/http' | |
URL = 'bucket_url' | |
DIGITS_AND_LETTERS = (0..9).to_a.concat(('a'..'z').to_a) | |
count = 0 | |
DIGITS_AND_LETTERS.repeated_permutation(32) do |num| | |
begin |
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
class BarController < ApplicationController | |
before_action :find_bar | |
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found | |
def show | |
end | |
private |
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
10.times do |num| | |
Post.create(title: "Ruby is Awesome #{num}", body: 'Indeed it is') do |post| | |
5.times { Comment.create(body: "Comment #{num}", post: post) } | |
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
<div> | |
posts: <%= @posts.count %> <br> | |
<% @posts.each do |post| %> | |
<%= post.title %> | |
<hr> | |
<%= post.body %> | |
<% if post.created_at < post.updated_at %> | |
(edited) | |
<% else %> | |
(first version) |
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
class PostsController < ApplicationController | |
def index | |
@posts = Post.all.order(id: :asc) | |
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
class Post < ApplicationRecord | |
has_many :comments | |
end | |
class Comment < ApplicationRecord | |
belongs_to :post | |
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
<div> | |
posts: <%= @posts.size %> <br> | |
<% @posts.each do |post| %> | |
<%= post['title'] %> | |
<hr> | |
<%= post['body'] %> | |
<%= post['status'] %> | |
<hr> | |
comments: <%= post['comments'].size %> <br> | |
<% post['comments'].each do |comment| %> |
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
class PostPresenter | |
def index | |
posts = Post.includes(:comments).order(id: :asc).as_json(include: [:comments]) | |
posts.map { |post| post['status'] = post['created_at'] < post['updated_at'] ? '(edited)' : '(first version)' } | |
end | |
end |
OlderNewer