Browse Source

lk | paginates bikes & orders by log # desc

master
Louis Knapp 9 years ago
parent
commit
cc3f0f8c77
  1. 1
      .gitignore
  2. 1
      Gemfile
  3. 2
      Gemfile.lock
  4. 10
      app/controllers/bikes_controller.rb
  5. 2
      app/views/bikes/index.html.haml
  6. 2
      app/views/bikes/print_select.html.haml

1
.gitignore

@ -22,6 +22,7 @@ dump.rdb
.DS_Store .DS_Store
/config/secrets.yml /config/secrets.yml
/ignored/
*.swp *.swp
/.vagrant/* /.vagrant/*

1
Gemfile

@ -9,6 +9,7 @@ gem 'oauth2', '1.0.0'
gem 'dotenv-rails' gem 'dotenv-rails'
gem 'sidekiq' gem 'sidekiq'
gem 'sinatra', :require => nil gem 'sinatra', :require => nil
gem 'will_paginate', '~> 3.0.6'
#SCSS & Bootstrap #SCSS & Bootstrap
gem 'bootstrap-sass', '2.3.2.0' gem 'bootstrap-sass', '2.3.2.0'

2
Gemfile.lock

@ -237,6 +237,7 @@ GEM
addressable (>= 2.3.6) addressable (>= 2.3.6)
crack (>= 0.3.2) crack (>= 0.3.2)
websocket (1.0.7) websocket (1.0.7)
will_paginate (3.0.7)
xpath (2.0.0) xpath (2.0.0)
nokogiri (~> 1.3) nokogiri (~> 1.3)
@ -278,6 +279,7 @@ DEPENDENCIES
turbolinks (= 1.1.1) turbolinks (= 1.1.1)
uglifier (= 2.1.1) uglifier (= 2.1.1)
webmock (= 1.21.0) webmock (= 1.21.0)
will_paginate (~> 3.0.6)
BUNDLED WITH BUNDLED WITH
1.10.6 1.10.6

10
app/controllers/bikes_controller.rb

@ -3,26 +3,24 @@ class BikesController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
def index def index
@bikes = Bike.all.order(:log_number).reverse_order @bikes = Bike.all.order(:log_number).reverse_order.paginate(:page => params[:page], :per_page => 30)
@unsold_bikes = @bikes.select{ |bike| @unsold_bikes = @bikes.select{ |bike|
!bike.date_sold && !bike.date_sold &&
(bike.purpose == "Sale") (bike.purpose == "Sale")
} }
end end
def show def show; end
end
def new def new
@bike = Bike.new @bike = Bike.new
@log_number = Bike.order(:log_number).last.log_number + 1 @log_number = Bike.order(:log_number).last.log_number + 1
end end
def edit def edit; end
end
def print_select def print_select
@bikes = Bike.all @bikes = Bike.order(:log_number).reverse_order.paginate(:page => params[:page], :per_page => 30)
end end
def print_labels def print_labels

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

@ -34,4 +34,4 @@
%td= bike.model %td= bike.model
%td= link_to 'Show', bike %td= link_to 'Show', bike
%td= link_to 'Edit', edit_bike_path(bike) %td= link_to 'Edit', edit_bike_path(bike)
=will_paginate @bikes

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

@ -11,4 +11,6 @@
%tr %tr
%td= bike.name %td= bike.name
%td= check_box("print_bikes", bike.id) %td= check_box("print_bikes", bike.id)
=will_paginate @bikes
%br
=submit_tag 'Generate Labels', class: "btn btn-default" =submit_tag 'Generate Labels', class: "btn btn-default"

Loading…
Cancel
Save