From 1f8371c10eee589b7b329df18b53ab4b0c3d57db Mon Sep 17 00:00:00 2001 From: Louis Knapp Date: Sun, 11 Oct 2015 12:37:54 -0500 Subject: [PATCH] lk | bike#edit uses different _form than bike#new --- .../{_form.html.haml => _edit_form.html.haml} | 2 +- app/views/bikes/_fields.html.haml | 2 +- app/views/bikes/_new_form.html.haml | 12 ++++++++++++ app/views/bikes/edit.html.haml | 2 +- app/views/bikes/index.html.haml | 16 ++++------------ app/views/bikes/new.html.haml | 2 +- 6 files changed, 20 insertions(+), 16 deletions(-) rename app/views/bikes/{_form.html.haml => _edit_form.html.haml} (83%) create mode 100644 app/views/bikes/_new_form.html.haml diff --git a/app/views/bikes/_form.html.haml b/app/views/bikes/_edit_form.html.haml similarity index 83% rename from app/views/bikes/_form.html.haml rename to app/views/bikes/_edit_form.html.haml index a2f9679..895b94c 100644 --- a/app/views/bikes/_form.html.haml +++ b/app/views/bikes/_edit_form.html.haml @@ -9,4 +9,4 @@ .row .actions.col-sm-offset-2 - = f.submit value: "Log another bike", class: "btn btn-default" + = f.submit value: "Update", class: "btn btn-default" diff --git a/app/views/bikes/_fields.html.haml b/app/views/bikes/_fields.html.haml index 5288ac4..ea36f4a 100644 --- a/app/views/bikes/_fields.html.haml +++ b/app/views/bikes/_fields.html.haml @@ -87,4 +87,4 @@ %span.input-group-addon $ = f.text_field :price, class: "form-control", disabled: disabled - %a{href: "http://www.bicyclebluebook.com/SearchBikes.aspx"} Look It Up + %a{href: "http://www.bicyclebluebook.com/SearchBikes.aspx"} Look It Up diff --git a/app/views/bikes/_new_form.html.haml b/app/views/bikes/_new_form.html.haml new file mode 100644 index 0000000..085425f --- /dev/null +++ b/app/views/bikes/_new_form.html.haml @@ -0,0 +1,12 @@ += form_for @bike, html: {class: 'form-horizontal'} do |f| + - if @bike.errors.any? + #error_explanation + %h2= pluralize(@bike.errors.count, "error") + " prohibited this bike from being saved:" + %ul + - @bike.errors.full_messages.each do |msg| + %li= msg + = render 'fields', f: f + + .row + .actions.col-sm-offset-2 + = f.submit value: "+ Log Another", class: "btn btn-default" diff --git a/app/views/bikes/edit.html.haml b/app/views/bikes/edit.html.haml index ad1bb60..1f61eec 100644 --- a/app/views/bikes/edit.html.haml +++ b/app/views/bikes/edit.html.haml @@ -4,7 +4,7 @@ %h1 Edit bike .col-sm-3.col-sm-offset-3 =button_to "Mark as sold", {action: "mark_as_sold", id: @bike.id}, method: :patch, class: "btn btn-default" - = render 'form' + = render 'edit_form' = link_to 'Show', @bike | = link_to 'Back', bikes_path diff --git a/app/views/bikes/index.html.haml b/app/views/bikes/index.html.haml index 3213177..b0f8ee4 100644 --- a/app/views/bikes/index.html.haml +++ b/app/views/bikes/index.html.haml @@ -7,31 +7,23 @@ %table.table.table-striped.table-bordered.table-hover %thead %tr - %th Brand - %th Model - %th + %th Bike %th %tbody - @unsold_bikes.each do |bike| %tr - %td= bike.brand - %td= bike.model - %td= link_to 'Show', bike + %td= bike.name %td= link_to 'Edit', edit_bike_path(bike) %h1 All Bikes %table.table.table-striped.table-bordered.table-hover %thead %tr - %th Brand - %th Model - %th + %th Bike %th %tbody - @bikes.each do |bike| %tr - %td= bike.brand - %td= bike.model - %td= link_to 'Show', bike + %td= bike.name %td= link_to 'Edit', edit_bike_path(bike) =will_paginate @bikes diff --git a/app/views/bikes/new.html.haml b/app/views/bikes/new.html.haml index 7290769..3ab88d0 100644 --- a/app/views/bikes/new.html.haml +++ b/app/views/bikes/new.html.haml @@ -1,4 +1,4 @@ .container %h1 New bike - = render 'form' + = render 'new_form' = link_to 'Back', bikes_path