mirror of
https://github.com/fspc/bike-database.git
synced 2026-09-16 08:31:39 -04:00
lk | user can log multiple bikes in a row
This commit is contained in:
@@ -4,10 +4,7 @@ class BikesController < ApplicationController
|
||||
|
||||
def index
|
||||
@bikes = Bike.all.order(:log_number).reverse_order.paginate(:page => params[:page], :per_page => 30)
|
||||
@unsold_bikes = @bikes.select{ |bike|
|
||||
!bike.date_sold &&
|
||||
(bike.purpose == "Sale")
|
||||
}
|
||||
@unsold_bikes = @bikes.select{|bike| bike.date_sold.nil? && bike.purpose == "Sale"}
|
||||
end
|
||||
|
||||
def show; end
|
||||
@@ -31,7 +28,7 @@ class BikesController < ApplicationController
|
||||
def create
|
||||
@bike = Bike.new(bike_params)
|
||||
if @bike.save
|
||||
redirect_to @bike, notice: 'Bike was successfully created.'
|
||||
redirect_to new_bike_path, notice: 'Bike was successfully created.'
|
||||
else
|
||||
render action: 'new'
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
= form_for @bike, html: {class: 'form-horizontal'} do |f|
|
||||
- if @bike.errors.any?
|
||||
- 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
|
||||
%li= msg
|
||||
= render 'fields', f: f
|
||||
|
||||
.row
|
||||
.actions.col-sm-offset-2
|
||||
= f.submit class: "btn btn-default"
|
||||
= f.submit value: "Log another bike", class: "btn btn-default"
|
||||
|
||||
Reference in New Issue
Block a user