- Add image to User
- Add a link to the sidebar to "Favorite cats"
- Add like / unlike to cat's show page
- Show like counter for each cat
- Add 'mini-feed' to user's show page with first 3 cats and link to more
.media-grid { | |
width: 100%; | |
} | |
.media-grid > li { | |
float: left; | |
display: block; | |
margin-right: 20px; | |
margin-bottom: 20px; |
<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 %> |
<h1>[username] details:</h1> | |
<table> | |
<tr> | |
<th>Username</th> | |
<td>[username]</td> | |
</tr> | |
<tr> | |
<th>First name</th> | |
<td>[first name]</td> |
<h1>User list</h1> | |
<table> | |
<tr> | |
<th>Id</th> | |
<th>Username</th> | |
</tr> | |
- For each user | |
<tr> |
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 } |
# 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 } |
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