application.scss.erb - use <%= asset_path 'background.jpg' %>
on config/environments/production.rb
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
# These are my notes from the PragProg book on CoffeeScript of things that either | |
# aren't in the main CS language reference or I didn't pick them up there. I wrote | |
# them down before I forgot, and put it here for others but mainly as a reference for | |
# myself. | |
# assign arguments in constructor to properties of the same name: | |
class Thingie | |
constructor: (@name, @url) -> | |
# is the same as: |
By default, Rails applications build URLs based on the primary key -- the id
column from the database. Imagine we have a Person
model and associated controller. We have a person record for Bob Martin
that has id
number 6
. The URL for his show page would be:
/people/6
But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6
here, is called the "slug". Let's look at a few ways to implement better slugs.
# Asserting a link based on HREF | |
Then /^(?:|I )should see a link to (.+?)(?: with the text "([^\"]*)")?(?: within "([^\"]*)")?$/ do |page_name, text, selector| | |
with_scope(selector) do | |
page.should have_css("a[href='#{ path_to(page_name) }']", :text => text) | |
end | |
end | |
Then /^(?:|I )should see a mailto link for "([^\"]*)"(?: with the text "([^\"]*)")?(?: within "([^\"]*)")?$/ do |email_address, text, selector| | |
with_scope(selector) do |
# Adapted from a C# example here: | |
# http://stackoverflow.com/questions/43224/how-do-i-calculate-a-trendline-for-a-graph | |
# And thanks to John Esser for helping figure out how to | |
# calculate the targets to stabilize a negative slope! | |
class LinearRegression | |
attr_accessor :slope, :intercept | |
# Pass in an array of values to get the regression on |
# Use the config/mongoid/#{rails_env}.yml file for mongoid config | |
namespace :mongoid do | |
desc "Copy mongoid config" | |
task :copy do | |
upload "config/mongoid/#{rails_env}.yml", "#{shared_path}/mongoid.yml", :via => :scp | |
end | |
desc "Link the mongoid config in the release_path" | |
task :symlink do |
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
# See http://m.onkey.org/running-rails-performance-tests-on-real-data | |
# fixed to work with Rails 3.2.8 | |
# START : HAX HAX HAX | |
# Load Rails environment in 'test' mode | |
RAILS_ENV = "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
# Re-establish db connection for 'performance' mode | |
silence_warnings { RAILS_ENV = "performance" } |
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |