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
begin | |
require "sequel" | |
rescue LoadError | |
$stderr.puts "You don't have sequel installed in your application. Please add it to your Gemfile and run bundle install" | |
raise | |
end | |
Sequel::Model.plugin :active_model | |
module Trestle |
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
## Trestle Contributor License Agreement | |
In order to clarify the intellectual property license granted with Contributions from any person or entity, the Trestle Project (the "Project") must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the Project and its users; it does not change your rights to use your own Contributions for any other purpose. | |
The following terms are used throughout this agreement: | |
* You - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any entity that controls or is controlled by the legal entity, or is under common control with it. | |
* Project - is an umbrella term that refers to any and all projects within the Trestle organization. | |
* Contribution - any type of work that is submitted to a Project, including any modifications or additions to existing work. | |
* Sub |
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
$ rails console | |
Loading development environment (Rails 3.2.16) | |
> u = Wheelhouse::User.first | |
> u.password = u.password_confirmation = "newpassword" | |
> u.save |
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
# Replace relevant section in config/initializers/devise.rb | |
# ==> ORM configuration | |
# Load and configure the ORM. Supports :active_record (default) and | |
# :mongoid (bson_ext recommended) by default. Other ORMs may be | |
# available as additional gems. | |
require 'devise/orm/mongomodel' |
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 extract_extensions(filename) | |
extensions, *name = filename.split(".").reverse.slice_before { |f| f[" "] }.to_a | |
[name.flatten.reverse.join("."), extensions.reverse] | |
end | |
describe "#extract_extensions" do | |
specify { extract_extensions("some file name.with dots.html.markdown").should == ["some file name.with dots", ["html", "markdown"]]} | |
specify { extract_extensions("some file name with.dots.html.markdown").should == ["some file name with", ["dots", "html", "markdown"]]} | |
specify { extract_extensions("a b.c d.e").should == ["a b.c d", ["e"]] } | |
specify { extract_extensions("a.b c.a").should == ["a.b c", ["a"]] } |
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 Locale | |
def initialize(identifier) | |
@identifier = identifier.to_s | |
end | |
def to_mongo | |
@identifier | |
end | |
def self.from_mongo(mongo) |
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
module Rack | |
class GoogleAnalytics | |
TRACKING_CODE = <<-EOCODE | |
<script type="text/javascript"> | |
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); | |
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); | |
</script> | |
<script type="text/javascript"> | |
try { | |
var pageTracker = _gat._getTracker("{{ID}}"); |
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 disabled | |
# no-op | |
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
<% disabled do %> | |
Everything within this block will not get executed or output. | |
<% raise 'Foobar' # Even Ruby code won't be run %> | |
<% 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 RecipesController < ApplicationController | |
... | |
def new | |
@recipe = flash[:recipe] || Recipe.new | |
end | |
def create | |
@recipe = Recipe.new(params[:recipe]) | |
NewerOlder