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
| development: | |
| adapter: mysql2 | |
| encoding: utf8 | |
| reconnect: false | |
| database: Ponto | |
| pool: 5 | |
| username: root | |
| password: root | |
| socket: /var/run/mysqld/mysqld.sock | |
| test: |
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 Venda < ActiveRecord::Base | |
| has_and_belongs_to_many :users | |
| end | |
| class User < ActiveRecord::Base | |
| has_and_belongs_to_many :vendas | |
| end | |
| class UsersVendas < ActiveRecord::Base | |
| 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 User < ActiveRecord::Base | |
| has_many :sales | |
| has_many :products, :through => :sales | |
| end | |
| class Sale < ActiveRecord::Base | |
| belongs_to :product | |
| belongs_to :user | |
| 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
| def create | |
| @sale = Sale.new(sale_params) | |
| if @sale.amount <= @product.amount | |
| redirect_to root_path, :notice => "Quantidade indisponível" | |
| else | |
| @sale.save | |
| respond_with(@sale) | |
| end | |
| 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 DVD < Midia | |
| def initialize(titulo, valor, categoria) | |
| @titulo = titulo | |
| @valor = valor | |
| @categoria = categoria | |
| end | |
| def to_s | |
| %Q{ Título: #{@titulo}, Valor: #{@valor} } | |
| end | |
| 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
| require "fileutils" | |
| class Revista | |
| def self.find(id) | |
| raise DocumentNotFound, | |
| "Arquivo db/revistas/#{id} não encontrado.", caller | |
| unless File.exists?("db/revistas/#{id}.yml") | |
| YAML.load File.open("db/revistas/#{id}.yml", "r") | |
| encontrado | |
| end | |
| 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
| require 'fileutils' | |
| module ActiveFile | |
| def save | |
| @new_record = false | |
| File.open("db/revistas/#{@id}.yml", "w") do |file| | |
| file.puts serialize | |
| end | |
| 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
| = simple_form_for @product, html: { multipart: true } do |f| | |
| - if @product.errors.any? | |
| #errors | |
| %h2 | |
| = pluralize(@product.errors.count, "error") | |
| prevented this product from saving | |
| %ul | |
| - @product.errors.full_messages.each do |msg| | |
| %li= msg |
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 Meta | |
| def initialize(meta = {}) | |
| @meta = meta | |
| end | |
| def atingir_meta(meta) | |
| return meta | |
| end | |
| def dobrar_meta(meta) | |
| meta*2 | |
| 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
| Vagrant.configure(2) do |config| | |
| config.vm.box = "fnando/hellobits-trusty32" | |
| end |
OlderNewer