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
1 - rails new concern | |
rails generate model Product name company:text | |
rails generate model Category name:text | |
rails generate model Tag name:text product_id category_id:integer | |
2 - Arquivo seed | |
require 'faker' | |
produtos = (1..100).to_a | |
categorias = (1..5).to_a |
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
1 - rails new scope | |
2- rails generate model User name:string email:string born:date gender:string | |
rake db:migrate | |
3- sexo = [ "Masculino", "Feminino" ] | |
1_000.times do |i| | |
User.create(name: Faker::Company.name, email: Faker::Internet.email, born: Faker::Date.between(10000.days.ago, Date.today), gender: sexo.sample) | |
end |
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
class Calculadora | |
def soma(a, b) | |
a + b | |
end | |
def divide(a, b) | |
a / b | |
end | |
def multiplica(a, b) |
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
class User | |
def name | |
@name | |
end | |
def name=(name) | |
@name = name | |
end | |
def age |