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 is working in a Rails 3/1.9.2 app | |
# For using Capybara in Test/Unit Integration tests -- majority of this taken from the tartare-rails gem | |
# Make sure you have the capybara gem installed -- gem install capybara | |
# You can also create a folder: Rails_root/test/integration/helpers and place Files within to abstract some of the Capybara steps.... | |
require 'capybara/rails' | |
module ActionController | |
class IntegrationTest |
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
# I struggled with getting a fading flash[:notice] that would work both with standard served pages as well | |
# as ajax requests. I saw a number of posts online but did not have luck with or they seemed too | |
# complicated. This is what I ended up with from experimentation. | |
# Place the following code in application_helper.rb. Note that you need to either change or name your | |
# containers as I have in this code: | |
# application_helper.rb | |
module ApplicationHelper | |
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
ruby-1.8.7-p334 :002 > ruby-1.8.7-p334 :002 > DateTime.now.methods.sort | |
=> ["+", "-", "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>", "__id__", "__send__", "_dump", "`", "acts_like?", "ajd", "amjd", "as_json", "asctime", "b64encode", "between?", "binding_n", "blank?", "breakpoint", "class", "class_eval", "clone", "copy_instance_variables_from", "ctime", "cwday", "cweek", "cwyear", "day", "day_fraction", "dclone", "debugger", "decode64", "decode_b", "display", "downto", "dup", "duplicable?", "enable_warnings", "encode64", "england", "enum_for", "eql?", "equal?", "extend", "freeze", "frozen?", "gem", "gregorian", "gregorian?", "hash", "hour", "html_safe?", "id", "inspect", "instance_eval", "instance_exec", "instance_of?", "instance_values", "instance_variable_defined?", "instance_variable_get", "instance_variable_names", "instance_variable_set", "instance_variables", "is_a?", "italy", "jd", "julian", "julian?", "kind_of?", "ld", "leap?", "load", "load_dependency", "mday", "method", "methods", "min" |
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
# the point of this is to add simple lookup table-like values to an AR model or really any other rails class. | |
# it assumes that if you have a lookup named :some_lookup that the model will have a :some_lookup_id field | |
# EXAMPLE: | |
class MyModel < ActiveRecord::Base | |
include Lookup | |
lookup_for :function_type do | |
[ |
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
# config/initializers/app_config.rb | |
APP_CONFIG = AppConfig.new(YAML.load_file("#{Rails.root}/config/application.yml")[Rails.env]) | |
# then you have application.yml or whatever you want to call it: | |
# config/application.yml (or some better name) | |
development: | |
<<: *defaults |
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 'spec_helper' | |
describe Lookup do | |
# in theory this should work with an active record query or whatever code returning an appropriate array | |
# of hashes in the result in the block passed, but not going this far to test right now | |
describe 'with an object for lookup data' do | |
class MyClass | |
include Lookup |
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
I love unicode line breaks! |