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 app { | |
server unix:///path/to/rails/puma.sock fail_timeout=0; | |
} | |
server { | |
server_name 1.2.3.4 www.myrailsapp.com; | |
root /path/to/rails/public; | |
location ^~ /assets/ { | |
gzip_static on; |
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
# Place in /config/puma/production.rb | |
rails_env = "production" | |
environment rails_env | |
app_dir = "/path/to/my/rails-app" # Update me with your root rails app path | |
bind "unix://#{app_dir}/puma.sock" | |
pidfile "#{app_dir}/puma.pid" | |
state_path "#{app_dir}/puma.state" |
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
[Unit] | |
Description=Puma HTTP Server | |
After=network.target | |
[Service] | |
Type=simple | |
User=myuser | |
WorkingDirectory=/path/to/my/rails-app | |
Environment=RAILS_ENV=production |
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
# frozen_string_literal: true | |
require 'capistrano/setup' | |
require 'capistrano/deploy' | |
require 'capistrano/scm/git' | |
require 'capistrano/rvm' | |
require 'capistrano/bundler' | |
install_plugin Capistrano::SCM::Git | |
require 'capistrano/rails/console' |
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
def index | |
default_order = "created_at" | |
case current_user.role | |
when User::Roles[:admin] # 1 | |
default_order = "campo1" | |
when User::Roles[:other] # 2 | |
default_order = "campo2" | |
else | |
default_order = "campon" | |
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
data = [{nombre: 'Juan', color: 'azul', edad: '50' }, {nombre: 'Carlos', color: 'verde', edad: '20' } ] | |
<table> | |
<thead> | |
<tr> | |
<th>Nombre</th> | |
<th>Color</th> | |
<th>Edad</th> | |
</tr> | |
</thead> |
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
t.integer :status, default: User::Statuses[:active] |
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
# From | |
User::ACTIVE # => 1 | |
User::INACTIVE # => 0 | |
User::SUSPENDED # => 2 | |
# To | |
User::Statuses[:active] # => 1 | |
User::Statuses[:inactive] # => 0 | |
User::Statuses[:suspended] # => 2 |
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
<%= @user.status_name %> |
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
<%= f.select_tag :status, options_for_select(User.statuses_for_select, @user.status) %> |