Class: CategoryController
- Defined in:
- lib/controllers/category_controller.rb
Instance Method Summary collapse
Instance Method Details
#list ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/controllers/category_controller.rb', line 6 def list @title = $i18n.setup_categories layout(:menu) @center.clear do stack(:width => 0.5) { container ($i18n.new_category) { visit "/categories/new" } Category.all.each {|category| flow(:width => 1.0, :margin_left => 20) { separator_line } flow(:width => 1.0, :margin_left => 20) { flow(:width => 0.6, :margin_top => 8) { para category.name } flow(:width => 0.1) flow(:width => 0.3) { { category.destroy; visit '/categories' } } } } } end end |
#new ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/controllers/category_controller.rb', line 31 def new @title = $i18n.new_category layout(:menu) attrs = {} @center.clear do container flow { para $i18n.name edit_line('') do |edit| attrs[:name] = edit.text end } $i18n.create do if attrs[:name].blank? alert($i18n.name_cant_be_blank) elsif Category.filter(:name => attrs[:name]).any? alert($i18n.name_is_taken) else Category.create(attrs) visit '/categories' end end $i18n.cancel do visit '/categories' end end end |