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
#!/bin/bash | |
DBNAME=mydb | |
USER="david" | |
PASSWORD='mypassword123' | |
DATE=`date +"%Y%m%d"` | |
SQLFILE=$DBNAME-${DATE}.sql | |
BUCKETNAME=my-aws-bucket-name | |
cd | |
echo "Starting with the following data:" |
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
<%= @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) %> |
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 User < ActiveRecord::Base | |
Statuses = {inactive: 0, active: 1, suspended: 2, deleted: 3} | |
def self.statuses_for_select | |
{ | |
"Active" => Statuses[:active], | |
"Inactive" => Statuses[:inactive], | |
"suspended" => Statuses[:suspended], | |
"Deleted" => Statuses[:deleted] | |
} |
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 User < ActiveRecord::Base | |
Statuses = {inactive: 0, active: 1, suspended: 2, deleted: 3} | |
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 User < ActiveRecord::Base | |
ACTIVE = 1 | |
INACTIVE = 0 | |
SUSPENDED = 2 | |
DELETED = 3 | |
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
# 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
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
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 |
OlderNewer