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
gem 'rails', '3.1.0.rc5' | |
gem 'mongoid' | |
gem 'bson_ext' | |
gem 'paperclip' # Upload images for the gallery | |
gem 'devise' # Authentication | |
gem 'cancan' # Authorization | |
gem 'haml' # Markup | |
gem 'redcarpet' # Markdown templates | |
gem 'dalli' # Memcached interface |
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
# Normal app setup | |
module AppName | |
class Application < Rails::Application | |
# Other stuff unnecessary to this | |
# Here's the money-maker | |
config.release_status = ENV['RELEASE_STATUS'].to_sym || :beta | |
end | |
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
=form_for :newsletter_subscription, method: 'post', class: 'subscribe clearfix' do |f| | |
=f.email_field :email, '', placeholder: 'Your e-mail address', class: 'subscribe-field' | |
=image_submit_tag 'mail-ico.png', class: 'subscribe-button', alt: 'Subscribe' |
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
// I've never seen it written this way | |
myFunction(function() { | |
doSomethingJavascripty() }) |
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
require 'article' | |
require 'user' | |
class ArticleMapper < Perpetuity::Mapper | |
include Perpetuity::ActiveModelWrapper | |
attribute :title, String | |
attribute :body, String | |
attribute :author, User | |
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
class ArticlesController < ApplicationController | |
def edit | |
@article = ArticleMapper.find(params[:id]) | |
@article_model = Perpetuity::ActiveModel.new(article) | |
end | |
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
# Attribute class would go into the DB layer | |
class Attribute | |
def initialize name | |
@name = name | |
end | |
# For attribute == value | |
# For demo purposes, I didn't feel like implementing other comparators | |
def == value | |
{ @name => value } |
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_for @article do |f| %> | |
<div class="field"> | |
<%= f.label :title %> | |
<%= f.text_field :title %> | |
</div> | |
<div class="field"> | |
<%= f.label :body %> | |
<%= f.text_area :body %> | |
</div> | |
<% 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
describe ThingsController do | |
describe '#create' do | |
let(:thing_data) { { name: 'Name' } } | |
it 'creates a new Thing and hits the DB 3x' do | |
expect { post :create, thing: thing_data }.to change { Thing.count }.by 1 | |
# other response-related expectations here | |
end | |
it 'creates a new Thing and hits the DB once' do | |
post :create, thing: thing_data |
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> | |
<style> | |
p { | |
color: #f00; | |
font-size:48px; | |
text-shadow: #00f 0 0 10px; | |
} | |
</style> | |
<p>This is some text</p> |
OlderNewer