Browse Source

lk | bike#edit uses different _form than bike#new

master
Louis Knapp 9 years ago
parent
commit
1f8371c10e
  1. 2
      app/views/bikes/_edit_form.html.haml
  2. 12
      app/views/bikes/_new_form.html.haml
  3. 2
      app/views/bikes/edit.html.haml
  4. 16
      app/views/bikes/index.html.haml
  5. 2
      app/views/bikes/new.html.haml

2
app/views/bikes/_form.html.haml → 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"

12
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"

2
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

16
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

2
app/views/bikes/new.html.haml

@ -1,4 +1,4 @@
.container
%h1 New bike
= render 'form'
= render 'new_form'
= link_to 'Back', bikes_path

Loading…
Cancel
Save