Created
May 8, 2009 12:04
-
-
Save botanicus/108759 to your computer and use it in GitHub Desktop.
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
Encoding.default_internal | |
# => #<Encoding:UTF-8> | |
Encoding.default_external | |
# => #<Encoding:UTF-8> | |
Order.select.keys.first.encoding | |
# => #<Encoding:ASCII-8BIT> | |
Order.select.values.first.encoding | |
# => #<Encoding:ASCII-8BIT> |
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
# coding: utf-8 | |
require_relative "order_item" | |
require_relative "customer" | |
require_relative "payment_type" | |
class Order | |
include DataMapper::Resource | |
PER_PAGE ||= 20 | |
validates_present :customer, message: "Zákazník musí být vyplněn" | |
belongs_to :customer | |
belongs_to :payment_type | |
has n, :items, class_name: "OrderItem" | |
property :variable_symbol, Integer, key: true, auto_validation: false#, writer: :private | |
property :status, Enum[:unprocessed, :processed], default: :unprocessed | |
property :created_at, DateTime | |
property :updated_at, DateTime | |
property :referer, String | |
property :note, Text | |
# here we select data from db | |
# the data must be in UTF-8, but they are in US-ASCII (see irb.rb) | |
def self.select | |
instances = Hash.new | |
PaymentType.all.each do |instance| | |
instances[instance.shortcut] = instance.name | |
end | |
return instances | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment