@ -25,6 +25,16 @@ class BikesController < ApplicationController
@bikes = Bike.find(bike_ids)
end
def search
bike = Bike.where(log_number: params[:log_number]).first
if bike
redirect_to edit_bike_path(bike)
else
flash[:notice] = 'No bike with that log number was found'
redirect_to action: 'home', controller: 'static_pages'
def create
@bike = Bike.new(bike_params)
if @bike.save
@ -2,6 +2,10 @@
%h1 Bike & Client Tracker
%br
%h2 Bikes
= form_tag("bikes/search", method: "get", class: "form-inline") do
= label_tag(:log_number, "Search by log number:")
= text_field_tag :log_number, "", class: "form-control"
= submit_tag("Search", class: "btn btn-default")
= link_to "Log Bikes", new_bike_path
@ -7,6 +7,7 @@ Bikedb::Application.routes.draw do
mount Sidekiq::Web => '/sidekiq'
resources :bikes do
get 'search' => 'bikes#search', on: :collection
get 'print_select' => 'bikes#print_select', on: :collection
get 'print_labels' => 'bikes#print_labels', on: :collection
get 'freecyclery_pickup' => 'bikes#freecyclery_pickup', on: :collection