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
require 'acceptance_helper' | |
feature "Welcome Page" do | |
background do | |
50.times { Factory(:user) } | |
end | |
scenario "when user is not logged in" do | |
visit '/' | |
page.should have_content('Welcome! :)') |
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
require "rubygems" | |
require "ap" | |
unless IRB.version.include?('DietRB') | |
IRB::Irb.class_eval do | |
def output_value | |
ap @context.last_value | |
end | |
end | |
else # MacRuby |
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
# awesome git-enabled prompt | |
function parse_git_branch { | |
ref=$(git-symbolic-ref HEAD 2> /dev/null) || return | |
echo "("${ref#refs/heads/}")" | |
} | |
export PS1='\[\033[00;32m\]\u \[\033[00;35m\]\w\[\033[00m\]\[\033[00;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s` \[\033[00m\]\$ ' |
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
def recalculate! | |
self.number_of_questions = Match.connection.select_value("SELECT count(*) as c | |
FROM | |
responses as my_responses | |
LEFT JOIN | |
responses as their_responses | |
ON their_responses.user_id = #{user_b.id} | |
AND my_responses.question_id = their_responses.question_id | |
WHERE | |
my_responses.user_id = #{user_a.id} |
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
module ActiveRecord | |
class TablelessBase < ActiveRecord::Base | |
def self.columns() @columns ||= []; end | |
def self.column(name, sql_type = nil, default = nil, null = true) | |
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) | |
end | |
end | |
end |
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
def index | |
@users = User.latest.with_avatar | |
end | |
def random | |
@users = User.random.with_avatar.limit(21) | |
end | |
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
Add localized templates | |
# Default locale | |
app/views/messages/index.html.erb | |
# I18n.locale is set to :da (Danish) | |
app/views/messages/index.da.html.erb |
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
- set_page_title "Neuer User" |
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
- set_page_title do | |
%h1 | |
%strong Ein neuer User. | |
Wie spannend! |
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
# place this in application_helper.rb | |
def set_page_title(title = nil, &block) | |
if block_given? | |
html = capture(&block) | |
concat(html) | |
end | |
@page_title = title || strip_tags(html) | |
end |