- On the spreadsheet, there is a "Contacts" sheet, please put your bitbucket user under your name.
- Send me email so I add you to the repository
- Clone [email protected]:bardelas/all.git
- Add a file "yourname.txt" with something inside
- Update the server
Its very important to know Validations and Field types as we will use them alot in our code. Please take the time to read (or at least skim over) the validations list to see what kind of validations are possible.
Create a new model
This file contains hidden or 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
# Validate AGE is above 16 | |
# Validate First Name is longer than 5 characters | |
# Validate Username is unique | |
class User < ActiveRecord::Base | |
attr_accessible(:age, :first_name, :last_name, :username) | |
validates :age, numericality: { greater_than: 16 } | |
validates :first_name, length: { minimum: 5 } |
This file contains hidden or 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
class Cat < ActiveRecord::Base | |
attr_accessible :birthdate, :breed, :name | |
BREEDS = [:arabean, :asian, :bengal, :persian] | |
# Name must be present and between 5 and 20 characters | |
validates :name, length: { in: 5..20 } | |
# Breed must be one of the following: :arabean, :asian, :bengal, :persian | |
validates :breed, inclusion: { in: BREEDS } |
This file contains hidden or 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
<h1>User list</h1> | |
<table> | |
<tr> | |
<th>Id</th> | |
<th>Username</th> | |
</tr> | |
- For each user | |
<tr> |
This file contains hidden or 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
<h1>[username] details:</h1> | |
<table> | |
<tr> | |
<th>Username</th> | |
<td>[username]</td> | |
</tr> | |
<tr> | |
<th>First name</th> | |
<td>[first name]</td> |
This file contains hidden or 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
<ul class="media-grid"> | |
<% @cats.each do |cat| %> | |
<li class='thumbnail'> | |
<%= link_to cat_path(cat) do %> | |
<%= image_tag cat.image.url, alt: cat.name %> | |
<% end %> | |
<ul class="controls"> | |
<% if can_like?(cat) %><li><%= link_to 'Like', like_cat_path(cat), method: :post, :class => 'btn btn-mini' %></li><% end %> | |
<% if can_unlike?(cat) %><li><%= link_to 'UnLike', unlike_cat_path(cat), method: :post, :class => 'btn btn-mini' %></li><% end %> | |
<% if can_edit?(cat) %><li><%= link_to 'Edit', edit_cat_path(cat), :class => 'btn btn-mini' %></li><% end %> |