Skip to content

Instantly share code, notes, and snippets.

View Gregg's full-sized avatar
🙄
Contemplating why Github needs a status bar.

Gregg Pollack Gregg

🙄
Contemplating why Github needs a status bar.
View GitHub Profile
class Tweet < ActiveRecord::Base
has_many :categorizations
has_many :categories, through: :categorizations
end
class Categorization < ActiveRecord::Base
belongs_to :tweet
belongs_to :category
end
@Gregg
Gregg / _form.html
Created August 25, 2011 20:19
Weapon Form
<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="&#x2713;" /><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>
@Gregg
Gregg / show.html
Created August 24, 2011 15:07
view for weapons
<!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" />
@Gregg
Gregg / gist:968534
Created May 12, 2011 13:54
Code School Screencasting Framework

Screencasting Framework

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.

Why you should care about screencasting?

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.

  1. 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.
# 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])
We couldn’t find that file to show.
# 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
# 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:
# 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 %>
<% 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 %>