mirror of
https://github.com/fspc/bike-database.git
synced 2025-02-23 01:23:24 -05:00
lk | add ability to search by bike log #
This commit is contained in:
parent
7fa84acfd1
commit
bc3b5f8a1a
@ -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'
|
||||
end
|
||||
end
|
||||
|
||||
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")
|
||||
%br
|
||||
= link_to "Log Bikes", new_bike_path
|
||||
%br
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user