Skip to content

Instantly share code, notes, and snippets.

index.html.haml
%h1 Listing orders
%table
%tr
%th Name
%th Address
%th Email
_cart.html.haml
.cart_title = t('.title')
%table
= render(cart.line_items)
%tr.total_line
%td{:colspan => "2"} Total
%td.total_cell= number_to_currency(cart.total_price)
= button_to t('.checkout'), new_order_path, method: :get
= button_to t('.empty'), cart, method: :delete, confirm: 'Are you sure?'
!!!
%html
%head
= stylesheet_link_tag "application"
= javascript_include_tag "application"
= csrf_meta_tag
%body{:class => controller.controller_name}
#banner
= form_tag root_path, class: 'locale' do
= select_tag 'set_locale', options_for_select(LANGUAGES, I18n.locale.to_s), onchange: 'this.form.submit()'
class AddCategoryToFoodItems < ActiveRecord::Migration
def change
add_column :food_items, :string, :category
end
end
= render :partial => 'menu_header'
.menu
- @food_items.each do |food_item|
- if food_item.img_url?
%td.list_image
= image_tag(food_item.img_url)
%h3= food_item.name
%td.list_description
= sanitize(food_item.description)
= render :partial => 'menu_header'
.menus
- @food_items.each do |food_item|
- if food_item.img_url?
.list_image
= link_to image_tag(food_item.img_url), food_item.img_url
%h3= food_item.name
.list_description
= sanitize(food_item.description)
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'rake', '0.9.2'
gem 'heroku'
gem 'thin'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
class FoodItemMenusController < ApplicationController
skip_before_filter :authorize
def food_list
@foods = FoodItem.all
@food_list = @foods.group_by { |t| t.category }
end
end
= render :partial => 'menu_header'
.menus
= @foods.each do |category, foods|
= category
- foods.each do |foods|
- if foods.img_url?
.list_image
= link_to image_tag(foods.img_url, class: 'list_image'), asset_path(foods.img_url), target: 'new'
%h3= foods.name
= render :partial => 'menu_header'
.menus
- @foods.each do |category, foods|
.category
= category.titleize
.menus
- foods.each do |foods|
- if foods.img_url?
.list_image