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
<% current_user.who_to_follow.limit(5).each do |f| %> | |
<li><%= f.name %> - <%= link_to "Follow", follow_user_path(f) %></li> | |
<% end %> | |
# It's generally bad practice to have any code that queries your db right there in the view. You want to do the queries in your controller if at all possible. | |
<% @who_to_follow.each do |f| %> | |
<li><%= f.name %> - <%= link_to "Follow", follow_user_path(f) %></li> | |
<% 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
# Lets talk about helpers! See once again your main twitter page | |
# <div class="followers"> | |
# Followers | |
# <span><%= @followers_count %></span> | |
# <% @recent_followers.each do |f| %> | |
# <a href="<%= user_path(f) %>"> | |
# <img src="<%= f.avatar.url(:thumb) %>" /> | |
# </a> | |
# <% 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
# So you might have something like this: | |
# <% @presenter.tweets.each do |tweet| %> | |
# <div id="tweet_#{tweet.id}" class="<%= 'favorite' if current_user && tweet.is_a_favorite?(current_user) %>"> | |
# <%= tweet.status %> | |
# </div> | |
# <% end %> | |
# Kinda ugly... this is a simple example of where you might want a block helper so our view becomes: |
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
# if we want to effectively leverage SEO on our website, we'll want to provide custom title, description, and keywords on some of the pages... one way we can do this is: | |
# <!DOCTYPE html> | |
# <html> | |
# <head> | |
# <title>Big Store <%= @title %></title> | |
# <meta name="description" content="<%= @description || "Selling the best chaps ..." %>"> | |
# <meta name ="keywords" content="<%= @keywords || "chaps, cowboy shop, leather" %>"> | |
class ProductsController < ApplicationController |
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
# Objective | |
Refactor the Users#follow action and move code into the User model. Create the follow method in the User model. | |
# Before | |
class UsersController < ApplicationController | |
def follow | |
@user = User.find(params[:id]) | |
The following document is a written account of the Code School screencasting framework. It should be used as a reference of the accompanying screencast on the topic.
You're probably aren't going to take the time to read this document if you're not interested, but there are a lot of nice side effects caused by learning how to create quality screencasts.
- Communicating more effectively - At Envy Labs we produce screencasts for our clients all the time. Whether it's demoing a new feature or for a presentation for an invester, they're often much more effective and pleasent than a phone call or screen sharing.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Deleteme</title> | |
<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css" /> | |
<script src="/assets/application.js" type="text/javascript"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.js" type="text/javascript"></script> | |
<meta content="authenticity_token" name="csrf-param" /> | |
<meta content="wZv2EN60HHcPOGXmR2FvgsfE4Dditk52fSKPlmJk0KQ=" name="csrf-token" /> |
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
<form accept-charset="UTF-8" action="/users/2/weapons" class="new_weapon" id="new_weapon" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="wZv2EN60HHcPOGXmR2FvgsfE4Dditk52fSKPlmJk0KQ=" /></div> | |
<div class="field"> | |
<label for="weapon_name">Name</label><br /> | |
<input id="weapon_name" name="weapon[name]" size="30" type="text" /> | |
</div> | |
<div class="field"> | |
<label for="weapon_condition">Condition</label><br /> | |
<input id="weapon_condition" name="weapon[condition]" size="30" type="text" /> | |
</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
class Tweet < ActiveRecord::Base | |
has_many :categorizations | |
has_many :categories, through: :categorizations | |
end | |
class Categorization < ActiveRecord::Base | |
belongs_to :tweet | |
belongs_to :category | |
end |