From 8d488c86a059d0694582fa504459b16b05f6add8 Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Sun, 9 Dec 2012 13:15:38 -0500 Subject: [PATCH] Added Bike Status routes, Controller and views --- app/controllers/bike_statuses_controller.rb | 35 +++++++++++++++++++++ app/views/bike_statuses/_form.html.haml | 8 +++++ app/views/bike_statuses/edit.html.haml | 4 +++ app/views/bike_statuses/index.html.haml | 21 +++++++++++++ app/views/bike_statuses/new.html.haml | 4 +++ app/views/bike_statuses/show.html.haml | 13 ++++++++ config/routes.rb | 1 + 7 files changed, 86 insertions(+) create mode 100644 app/controllers/bike_statuses_controller.rb create mode 100644 app/views/bike_statuses/_form.html.haml create mode 100644 app/views/bike_statuses/edit.html.haml create mode 100644 app/views/bike_statuses/index.html.haml create mode 100644 app/views/bike_statuses/new.html.haml create mode 100644 app/views/bike_statuses/show.html.haml diff --git a/app/controllers/bike_statuses_controller.rb b/app/controllers/bike_statuses_controller.rb new file mode 100644 index 0000000..09d4090 --- /dev/null +++ b/app/controllers/bike_statuses_controller.rb @@ -0,0 +1,35 @@ +class BikeStatusesController < AuthenticatedController + expose(:bike_status) + + expose(:bike_statuses) { BikeStatus.order('id').paginate(:page => params[:page]) } + + def index + end + + def show + end + + def new + end + + def create + if bike_status.save + redirect_to bike_statuses_url + else + render :new + end + end + + def update + if bike_status.save + redirect_to bike_statuses_url + else + render :edit + end + end + + def destroy + bike_status.destroy + redirect_to bike_statuses_url + end +end diff --git a/app/views/bike_statuses/_form.html.haml b/app/views/bike_statuses/_form.html.haml new file mode 100644 index 0000000..0222831 --- /dev/null +++ b/app/views/bike_statuses/_form.html.haml @@ -0,0 +1,8 @@ += form_for bike_status, :html => { :class => 'form-horizontal' } do |f| + .control-group + = f.label :status, :class => 'control-label' + .controls + = f.text_field :status, :class => 'text_field' + .form-actions + = f.submit nil, :class => 'btn btn-primary' + = link_to t('.cancel', :default => t("helpers.links.cancel")), bike_statuses_path, :class => 'btn' diff --git a/app/views/bike_statuses/edit.html.haml b/app/views/bike_statuses/edit.html.haml new file mode 100644 index 0000000..8fdff03 --- /dev/null +++ b/app/views/bike_statuses/edit.html.haml @@ -0,0 +1,4 @@ +- model_class = bike_status.class +.page-header + %h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}") += render :partial => "form" diff --git a/app/views/bike_statuses/index.html.haml b/app/views/bike_statuses/index.html.haml new file mode 100644 index 0000000..86f78c2 --- /dev/null +++ b/app/views/bike_statuses/index.html.haml @@ -0,0 +1,21 @@ +- model_class = BikeStatus.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(:status) + %th= model_class.human_attribute_name(:created_at) + %th=t '.actions', :default => t("helpers.actions") + %tbody + - bike_statuses.each do |bike_status| + %tr + %td= link_to bike_status.id, bike_status_path(bike_status) + %td= bike_status.status + %td=l bike_status.created_at + %td + = link_to t('.edit', :default => t("helpers.links.edit")), edit_bike_status_path(bike_status), :class => 'btn btn-mini' + = link_to t('.destroy', :default => t("helpers.links.destroy")), bike_status_path(bike_status), :method => :delete, :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')), :class => 'btn btn-mini btn-danger' + += link_to t('.new', :default => t("helpers.links.new")), new_bike_status_path, :class => 'btn btn-primary' diff --git a/app/views/bike_statuses/new.html.haml b/app/views/bike_statuses/new.html.haml new file mode 100644 index 0000000..04de969 --- /dev/null +++ b/app/views/bike_statuses/new.html.haml @@ -0,0 +1,4 @@ +- model_class = bike_status.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_statuses/show.html.haml b/app/views/bike_statuses/show.html.haml new file mode 100644 index 0000000..2149068 --- /dev/null +++ b/app/views/bike_statuses/show.html.haml @@ -0,0 +1,13 @@ +- model_class = bike_status.class +.page-header + %h1=t '.title', :default => model_class.model_name.human + +%p + %strong= model_class.human_attribute_name(:status) + ':' + %br + = bike_status.status + +.form-actions + = link_to t('.back', :default => t("helpers.links.back")), bike_statuses_path, :class => 'btn' + = link_to t('.edit', :default => t("helpers.links.edit")), edit_bike_status_path(bike_status), :class => 'btn' + = link_to t('.destroy', :default => t("helpers.links.destroy")), bike_status_path(bike_status), :method => "delete", :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')), :class => 'btn btn-danger' diff --git a/config/routes.rb b/config/routes.rb index 4687b10..1923b60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,7 @@ Velocipede::Application.routes.draw do resources :bike_brands, :except => [:edit, :delete] resources :bike_models, :except => [:edit, :delete] + resources :bike_statuses #resources :clues #resources :maps