order = Order.find_by_name("Jakub Dunda")
orders = Order.find_all_by_name("Jakub Dunda")
orders = Order.find_all_by_email(params['email'])


orders = LineItem.find_by_sql(
  "select line_items.* from line_items, orders " +
  " where order_id = orders.id " +
  " and orders.name = 'Jakub Dunda' ")


orders = Order.find_by_sql("select name, pay_type from orders")
first = orders[0]
p first.attributes
p first.attribute_names
p first.attribute_present?("address")


items = LineItem.find_by_sql("select *, " +
  " products.price as unit_price, " +
  " quantity*products.price as total_price, " +
  " products.title as title " +
  " from line_items, products " +
  " where line_items.product_id = products.id ")
li = items[0]
puts "#{li.title}: #{li.quantity}x#{li.unit_price} => #{li.total_price}"
