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
function! SetupCoverage() | |
if filereadable("coverage.vim") | |
source coverage.vim | |
endif | |
endfunction | |
if has("autocmd") | |
autocmd FileType ruby call SetupCoverage() | |
endif |
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
var Activity = (function() { | |
var count = 0; | |
var show = $.fancybox.showActivity; | |
var hide = $.fancybox.hideActivity; | |
var start = function() { | |
++count; | |
show(); | |
}; |
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 'virtus' | |
class Foo | |
include Virtus | |
attribute :id, Integer | |
attribute :date, Date | |
attribute :foo, String | |
def initialize(attributes = {}) |
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
class Foo | |
extend AutoCoercions | |
coerce :date_gte, :date_lte, with: :to_date | |
coerce :trip_mode_eq, :trip_purpose_eq, :trip_count_gte, with: :to_i | |
coerce :select_random_winners, with: ->(v) { v == '1' } | |
coerce :random_winner_count, with: :to_i | |
def initialize(attributes = {}) | |
@attributes = self.class.apply_coercions(attributes) |
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
ActiveAdmin.register Foo do | |
collection_action :foo | |
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
deliveries = ActionMailer::Base.deliveries. # <= note extra `.` | |
assert_equal I18n.t('user_mailer.bid_confirmation_email.subject'), deliveries.first.subject | |
# => NoMethodError: undefined method `first' for nil:NilClass |
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
en: | |
date: | |
formats: | |
default: <%= Stamp.strftime_format("March 1, 1999") %> | |
short: <%= Stamp.strftime_format("Mon Jan 1") %> | |
ordinal: <%= Stamp.strftime_format("1st of Jan") %> | |
time: | |
formats: | |
default: etc... |
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
controller do | |
def create | |
# Extend create to set the current user in your model here | |
create! | |
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
# your-engine/lib/magic/rails/engine.rb | |
module Magic | |
module Rails | |
module Engine | |
## | |
# Automatically append all of the current engine's routes to the main | |
# application's route set. This needs to be done for ALL functional tests that | |
# use engine routes, since the mounted routes don't work during tests. | |
# |
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
class Image | |
def mark_as_deleted(build = nil) | |
# If there's only one undeleted build left, we should only delete the one passed in | |
# otherwise, we're free to delete them all, and we should delete self as well. | |
if build && self.has_more_than_one_undeleted_build? | |
build.mark_as_deleted | |
else | |
build.each(&:mark_as_deleted) | |
self.update_column :deleted_at, Time.current | |
end |