-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After a challenge from Mike on the last version, I tried to do this without building a whole, separate validation class. I couldn't get message to work on the 'presence' validation, so I did a separate validation function for it. I could have combined all of these into one large validation function, but I decided it was more interesting to make a number of simple validation functions instead.
- Loading branch information
G. Wade Johnson
committed
Oct 13, 2015
1 parent
a7c7a5a
commit 91c758e
Showing
4 changed files
with
59 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Place all the styles related to the Urls controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ | ||
.error { | ||
color: red; | ||
} |
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,11 +1,13 @@ | ||
<h1>URL Shortener</h1> | ||
<% if flash[:save_error] %> | ||
<p class="error"><%= flash[:save_error] %></p> | ||
<% if !@errors.nil? && @errors.size > 0 %> | ||
<% @errors.each do |err| %> | ||
<p class="error"><%= err %></p> | ||
<% end %> | ||
<% end %> | ||
<form id="new_url" method="post" action="<%= urls_path %>"> | ||
<input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>"/> | ||
<label for="#target">Target:</label> | ||
<input type="text" name="target" id="target" size="100" placeholder="http://example.com/cool_page.html" value="<%= flash[:target] || '' %>"> | ||
<input type="text" name="target" id="target" size="100" placeholder="http://example.com/cool_page.html" value="<%= @target || '' %>"> | ||
<button class="btn btn-primary" type="submit">Shorten</button> | ||
</form> | ||
<a href="<%= urls_path %>">Back to list</a> |