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
# This file is copied to ~/spec when you run 'ruby script/generate rspec' | |
# from the project root directory. | |
ENV["RAILS_ENV"] ||= 'test' | |
$:.unshift File.dirname(__FILE__) | |
require "rails_app/config/environment" | |
require 'rails/test_help' | |
require 'rspec/rails' |
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 'active_record' | |
require 'logger' | |
puts "Active Record #{ActiveRecord::VERSION::STRING}" | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'postgresql', | |
:database => 'test' | |
) |
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
<p id="notice"><%= notice %></p> | |
<ul> | |
<li> | |
<em>Name:</em> | |
<%= @weapon.name %> | |
</li> | |
<li> | |
<em>Condition:</em> | |
<span id="condition"><%= @weapon.condition %></span> | |
<%= link_to "Toggle", toggle_condition_user_weapon_path(@user, @weapon), remote: true %> |
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
source "http://rubygems.org" | |
gem 'sprockets', :git => 'git://github.com/sstephenson/sprockets.git' | |
gem 'coffee-script' | |
gem 'sass' | |
gem 'rack-test' | |
gem 'sinatra' |
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
# a lot of people in ruby do this | |
module Foo | |
extend self | |
def bar | |
'bar' | |
end | |
end | |
Foo.bar |
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
# by default, heredoc strings are treated like double-quoted ruby strings, which means you can do string interpolation: | |
<<-EOF | |
The time is #{Time.now} | |
EOF | |
# => The time is Wed Sep 14 10:04:29 -0400 2011 | |
# But you can create heredoc strings that are treated like single-quoted string, like this: | |
<<-'EOF' |
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
def products_page | |
@page.our_products? | |
end | |
helper_method :products_page | |
class Page | |
OUR_PRODUCTS_TITLE = 'Our Products' | |
def our_products? |
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
event = require('pilot/event') | |
Anchor = require('ace/anchor').Anchor | |
doc = ace_editor.session.getDocument() | |
editablePositions = [[1, 0, 2, 0]] # allow editong only the second row | |
jQuery.each editable, (index, row) -> | |
editablePositions.push [new Anchor(doc, row[0], row[1]), new Anchor(doc, row[2], row[3])] | |
Range = require('ace/range').Range |
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
# Unfortunately, you still have to create the routes somewhere in routes.rb | |
Your::Application.routes.draw do | |
root :to => 'controller#action' | |
end | |
mapper = ActionDispatch::Routing::Mapper.new(Rails.application.routes) | |
mapper.instance_exec do | |
match '/some/action' => "some#action" | |
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 Foo | |
def foo(x, y) | |
"foo! #{x} and #{y}" | |
end | |
def bar | |
# my imaginary syntax for "create functional reference from method foo with argument bar. | |
&(:foo, 5) | |
end | |
end |