This gist describes how to setup a rails backbone project with testing frameworks.
Example Gemfile to start with.
namespace 'rails' do | |
desc 'Renames the current app' | |
task 'rename' do | |
# Get the new name | |
new_name = ENV["NEW_NAME"].capitalize || nil | |
if new_name.nil? | |
puts "\nYou must pass in a new name" | |
exit | |
end | |
# config/initializers/will_paginate.rb | |
module WillPaginate | |
module ActionView | |
def will_paginate(collection = nil, options = {}) | |
options[:renderer] ||= BootstrapLinkRenderer | |
super.try :html_safe | |
end | |
class BootstrapLinkRenderer < LinkRenderer |
1. Use latest build | |
gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git' | |
2. Create an initializer | |
# /config/initializers/simple_form.rb | |
# Use this setup block to configure all options available in SimpleForm. | |
SimpleForm.setup do |config| | |
# Wrappers are used by the form builder to generate a complete input. | |
# You can remove any component from the wrapper, change the order or even |
# coding: utf-8 | |
# | |
# Encode any codepoint outside the ASCII printable range to an HTML character | |
# reference (http://bit.ly/KNupLT). | |
def encode(string) | |
string.each_codepoint.inject("") do |buffer, cp| | |
cp = "&#x#{cp.to_s(16)};" unless cp >= 0x20 && cp <= 0x7E | |
buffer << cp | |
end | |
end |
# Sync with the remote master | |
git pull | |
# Force your clone to look like HEAD | |
git reset --hard | |
# AGAIN, A WARNING: This can really break stuff! | |
# Run your filter branch command, replacing all instances of "password" with "your_password" | |
# The example looks for Ruby files ("*.rb"), you can change this to match your needs |
--colour | |
-I app |
class Game | |
attr_reader :rolls | |
def initialize(rolls) | |
@rolls = rolls | |
end | |
def score | |
frames.inject(0) do |score, frame| | |
score += FrameScorer.new(frame).score |
guard 'coffeescript', :input => 'app', :output => 'public/javascripts/app', :cli => '' | |
guard 'coffeescript', :input => 'spec/coffeescripts', :output => 'spec/javascripts' | |
guard 'compass' do | |
watch(/app\/stylesheets\/(.*)\.s[ac]ss/) | |
end | |
spec_location = "spec/coffeescripts/%s_spec" | |
guard 'jasmine-headless-webkit' do | |
watch(%r{^spec/coffeescripts/(.*)_spec\..*}) { |m| newest_js_file(spec_location % m[1]) } |
class FooController | |
respond_to :csv | |
def index | |
@foos = Foo.scoped | |
if stale?(:last_modified => Foo.something) | |
respond_with @gta do |format| | |
format.csv { stream_csv @foo } | |
end | |
end |