Browse Source

Show add another bike link after creating bike

denney-fix-saving-dates
Jason Denney 10 years ago
parent
commit
5c4007a1be
  1. 2
      app/assets/javascripts/bikes.js
  2. 1
      app/controllers/bikes_controller.rb
  3. 4
      app/views/bikes/show.html.haml

2
app/assets/javascripts/bikes.js

@ -21,7 +21,7 @@ $("#add_bike_submit").click(function(){
contentType: 'application/json', contentType: 'application/json',
dataType: "json", dataType: "json",
success: function(data, status, xhr){ success: function(data, status, xhr){
window.location = data.bikes[0].id; window.location = data.bikes[0].id + "?add_bike=1";
}, },
error: function(data, status ){ error: function(data, status ){
displayFormErrors(data.responseJSON); displayFormErrors(data.responseJSON);

1
app/controllers/bikes_controller.rb

@ -10,6 +10,7 @@ class BikesController < AuthenticatedController
def show def show
@bike = Bike.find_by_id(params[:id]) @bike = Bike.find_by_id(params[:id])
@task_list_id = @bike.task_list.id @task_list_id = @bike.task_list.id
@show_add_bike = true if params[:add_bike]
end end
end end

4
app/views/bikes/show.html.haml

@ -1,3 +1,7 @@
- if @show_add_bike
%p
%a{class: "btn btn-lg btn-block btn-info", href: new_bike_path} Add Another Bike?
%a{ class: "btn btn-default btn-lg", href: root_path} %a{ class: "btn btn-default btn-lg", href: root_path}
%span{ class:"icon-home"} %span{ class:"icon-home"}
%h2 #{@bike.shop_id}: #{@bike.bike_brand} %h2 #{@bike.shop_id}: #{@bike.bike_brand}

Loading…
Cancel
Save