-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
104 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,37 @@ | ||
class BracksController < ApplicationController | ||
before_action :authenticate_user, only: [:new] | ||
before_action :authenticate_user, only: [:new, :edit] | ||
before_action :set_brack, only: [:edit, :update] | ||
|
||
def index | ||
end | ||
|
||
def new | ||
end | ||
|
||
def edit | ||
unless request.referer && (URI(request.referer).path == "/bracks/new") | ||
render file: "/public/404" | ||
end | ||
end | ||
|
||
def update | ||
if @brack.update_attributes(brack_params) | ||
flash[:notice] = "New Bike Rack Added!" | ||
redirect_to bracks_path | ||
else | ||
flash[:error] = "There was an issue saving your new bike rack." | ||
redirect_to bracks_path | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_brack | ||
@brack = Brack.find(params[:id]) | ||
end | ||
|
||
def brack_params | ||
params.require(:brack).permit(:cross_streets, :owner) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<h1>Add a New Rack</h1> | ||
|
||
<div class="well"> | ||
<h4>Edit and Confirm Bike Rack Information</h4> | ||
<%= form_for @brack do |f| %> | ||
<div class="form-group"> | ||
<%= f.label :cross_streets %> | ||
<p>We tried autogenerating them for you, but we're not perfect:</p> | ||
<%= f.text_field :cross_streets, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :owner %> | ||
<p>Either your name or your organization's name:</p> | ||
<%= f.text_field :owner, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.submit "Save New Rack", class:"btn btn-primary" %> | ||
</div> | ||
|
||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters