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
FactoryGirl.define do | |
factory :user do | |
first_name 'John Doe' | |
last_name 'Doe' | |
trait :yolo do | |
first_name 'Spinder' | |
last_name 'Man' | |
end | |
factory :spinder, traits: [:yolo] | |
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
<%= form_for(@project) do |f| %> | |
<% if f.errors.any? %> | |
<div id='error_explanation'> | |
<h2><%= pluralize(f.errors.count, 'error') %> | |
prohibited this foo from being saved:</h2> | |
<ul> | |
<% f.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> |
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.constants.select do |constant_name| | |
constant = eval constant_name | |
if not constant.nil? and constant.is_a? Class and constant.superclass == ActiveRecord::Base | |
constant | |
end | |
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
require 'csv' | |
namespace :seed do | |
desc "seed some awesomeness" | |
task :awesomeness => :environment do | |
CSV.foreach(File.join(Rails.root, 'lib/assets/yolo.csv')) do |row| | |
Awesome.create(:attribute_a => row[0], :attribute_b => row[1]) | |
end | |
end | |
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
2.0.0dev :015 > raw_params = {"layout"=>"layout_04", "zone_ids"=>["", "", "", "50e5a81a421aa977fa00000b"]} | |
=> {"layout"=>"layout_04", "zone_ids"=>["", "", "", "50e5a81a421aa977fa00000b"]} | |
2.0.0dev :016 > params = ActionController::Parameters.new(raw_params) => {"layout"=>"layout_04", "zone_ids"=>["", "", "", "50e5a81a421aa977fa00000b"]} | |
2.0.0dev :017 > params.permit(:zone_ids => []) => {"zone_ids"=>["", "", "", "50e5a81a421aa977fa00000b"]} |
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 PerspectivesController < ApplicationController | |
# GET /perspectives | |
# GET /perspectives.json | |
def index | |
@perspectives = Perspective.all | |
unless params['perspective'] | |
@perspective = @perspectives.where(default: true).first || Perspective.new | |
else | |
@perspective = Perspective.new | |
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
source 'http://rubygems.org' | |
# source 'http://localhost:9292' | |
gemspec | |
group :test do | |
gem "simplecov", :require => false | |
gem "shoulda-matchers" | |
gem "shoulda-context" | |
gem "capybara-screenshot" |
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
<%= link_to '#' do %> | |
hiii <%= image_tag('/images/menu-arrow-down.gif') %> | |
<% 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
str = (0...MAX_NUM).map { |n| n.en.numwords }.join.gsub(/ and /, "").gsub(/\W/, "") | |
NoMethodError: undefined method `en' for 0:Fixnum |
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 create_report | |
if @inspection.type == 'RoutineInspection' | |
puts "---CR> CREATING ROUTINE INSPECTION REPORT" | |
pdf = routine_inspection_generic | |
else | |
puts "---CR> CREATING INGOING INSPECTION REPORT" | |
thread = Thread.new do | |
pdf = ingoing_inspection_nsw | |
end.join | |
end |