From 01923723ff68b49159b70390817f52ccc4f96b79 Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Sat, 8 Dec 2012 16:36:04 -0500 Subject: [PATCH] Add Bike Brand Controller and Views --- app/controllers/bike_brands_controller.rb | 30 +++++++++++++++++++++++ app/views/bike_brands/_form.html.haml | 8 ++++++ app/views/bike_brands/index.html.haml | 15 ++++++++++++ app/views/bike_brands/new.html.haml | 4 +++ app/views/bike_brands/show.html.haml | 11 +++++++++ config/routes.rb | 11 +++------ 6 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 app/controllers/bike_brands_controller.rb create mode 100644 app/views/bike_brands/_form.html.haml create mode 100644 app/views/bike_brands/index.html.haml create mode 100644 app/views/bike_brands/new.html.haml create mode 100644 app/views/bike_brands/show.html.haml diff --git a/app/controllers/bike_brands_controller.rb b/app/controllers/bike_brands_controller.rb new file mode 100644 index 0000000..373ef2a --- /dev/null +++ b/app/controllers/bike_brands_controller.rb @@ -0,0 +1,30 @@ +class BikeBrandsController < AuthenticatedController + expose(:bike_brand) do + if params[:id] + BikeBrand.find(params[:id]) + elsif params[:bike_brand] + BikeBrand.new(params[:bike_brand]) + else + BikeBrand.new + end + end + + expose(:bike_brands) { BikeBrand.order('id').paginate(:page => params[:page]) } + + def index + end + + def show + end + + def new + end + + def create + if bike_brand.save + redirect_to bike_brands_url + else + render :new + end + end +end diff --git a/app/views/bike_brands/_form.html.haml b/app/views/bike_brands/_form.html.haml new file mode 100644 index 0000000..240b1eb --- /dev/null +++ b/app/views/bike_brands/_form.html.haml @@ -0,0 +1,8 @@ += form_for bike_brand, :html => { :class => 'form-horizontal' } do |f| + .control-group + = f.label :brand, :class => 'control-label' + .controls + = f.text_field :brand, :class => 'text_field' + .form-actions + = f.submit nil, :class => 'btn btn-primary' + = link_to t('.cancel', :default => t("helpers.links.cancel")), bike_brands_path, :class => 'btn' diff --git a/app/views/bike_brands/index.html.haml b/app/views/bike_brands/index.html.haml new file mode 100644 index 0000000..6b831e5 --- /dev/null +++ b/app/views/bike_brands/index.html.haml @@ -0,0 +1,15 @@ +- model_class = BikeBrand.new.class +.page-header + %h1=t '.title', :default => model_class.model_name.human.pluralize +%table.table.table-striped + %thead + %tr + %th= model_class.human_attribute_name(:id) + %th= model_class.human_attribute_name(:brand) + %tbody + - bike_brands.each do |bike_brand| + %tr + %td= link_to bike_brand.id, bike_brand_path(bike_brand) + %td= link_to bike_brand.brand, bike_brand_path(bike_brand) += will_paginate bike_brands += link_to t('.new', :default => t("helpers.links.new")), new_bike_brand_path, :class => 'btn btn-primary' diff --git a/app/views/bike_brands/new.html.haml b/app/views/bike_brands/new.html.haml new file mode 100644 index 0000000..a9cea53 --- /dev/null +++ b/app/views/bike_brands/new.html.haml @@ -0,0 +1,4 @@ +- model_class = bike_brand.class +.page-header + %h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}") += render :partial => "form" diff --git a/app/views/bike_brands/show.html.haml b/app/views/bike_brands/show.html.haml new file mode 100644 index 0000000..39714ef --- /dev/null +++ b/app/views/bike_brands/show.html.haml @@ -0,0 +1,11 @@ +- model_class = bike_brand.class +.page-header + %h1=t '.title', :default => model_class.model_name.human + +%p + %strong= model_class.human_attribute_name(:brand) + ':' + %br + = bike_brand.brand + +.form-actions + = link_to t('.back', :default => t("helpers.links.back")), bike_brands_path, :class => 'btn' diff --git a/config/routes.rb b/config/routes.rb index 58a4d7a..b624da3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,14 +7,11 @@ Velocipede::Application.routes.draw do match 'site/index' => 'site#index' - resources :teams, :except => [:edit, :delete] do - member do - post :join - end - end + resources :bike_brands, :except => [:edit, :delete] + + #resources :clues + #resources :maps - resources :clues - resources :maps # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action