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
| ENV["RAILS_ENV"] = "test" | |
| require File.expand_path(File.dirname(__FILE__) + "/../config/environment") | |
| require 'test_help' | |
| require 'shoulda' | |
| require File.expand_path(File.dirname(__FILE__) + "/blueprints.rb") | |
| class ActiveSupport::TestCase | |
| # Drop all collections after each test case. | |
| def teardown |
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
| config.cache_classes = true | |
| config.whiny_nils = true | |
| config.action_controller.consider_all_requests_local = true | |
| config.action_controller.perform_caching = false | |
| config.action_view.cache_template_loading = true | |
| config.action_controller.allow_forgery_protection = false |
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
| config = YAML.load(File.read(File.join(Rails.root, "config", "mongo.yml"))) | |
| MongoMapper.setup(config, Rails.env, { :logger => Rails.logger }) | |
| module IdentityMapAddition | |
| def self.included(model) | |
| model.plugin MongoMapper::Plugins::IdentityMap | |
| end | |
| end | |
| MongoMapper::Document.append_inclusions(IdentityMapAddition) |
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
| # Be sure to restart your server when you modify this file | |
| # Specifies gem version of Rails to use when vendor/rails is not present | |
| RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION | |
| # Bootstrap the Rails environment, frameworks, and default configuration | |
| require File.join(File.dirname(__FILE__), 'boot') | |
| Rails::Initializer.run do |config| | |
| config.load_once_paths += %W( #{Rails.root}/lib ) |
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
| PROMPT='%{$fg_bold[blue]%}%1~%{$reset_color%}%{$fg[red]%} %{$fg[green]%}ᐅ%{$reset_color%} ' | |
| RPROMPT='$(git_prompt_info) %{$reset_color%}%{$fg_bold[grey]%}$(~/.rvm/bin/rvm-prompt v g)%{$reset_color%}' | |
| ZSH_THEME_GIT_PROMPT_PREFIX="%{$bg_bold[black]%}%{$fg[yellow]%} " | |
| ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
| ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} ✓ %{$fg[yellow]%}" | |
| ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%} ⚡ %{$fg[yellow]%}" |
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
| # create a file called 'quiet_assets.rb' in the initializers directory, and put this code in-- | |
| Rails.application.assets.logger = Logger.new('/dev/null') | |
| Rails::Rack::Logger.class_eval do | |
| def call_with_quiet_assets(env) | |
| previous_level = Rails.logger.level | |
| Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0 | |
| call_without_quiet_assets(env).tap do | |
| Rails.logger.level = previous_level | |
| 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
| # create a file in initializers directory called "beautify_log.rb" (or whatever you want) and put in this code -- | |
| # | |
| # ActiveSupport patches | |
| # | |
| module ActiveSupport | |
| # Format the buffered logger with timestamp/severity info. | |
| class BufferedLogger |
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
| # NOTES | |
| # - many of my style changes reflect the excellent Github Ruby Style Guide | |
| # https://github.com/styleguide/ruby/ | |
| # - convention for naming Time-based db fields is xxxx_at, Date-based is xxxx_on | |
| # - naming methods find_by_blah_blah_blah is old, Rails 1-ish. Newer convention is just simple names | |
| # and scoping, so you can do things like: user.named('Bob').with_children(2) | |
| # ( as opposed to: user.find_by_name_and_children('Bob', 2) ) |
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
| # ====== TODAY'S KATA: | |
| # * create an Achievements API | |
| # * create an Achievement model, a User model, and a db table for many-many relationship between the two | |
| # * now, write the Goliath+Grape code to create 3 endpoints: | |
| # * 1. an endpoint to SHOW an Achievement (GET /v1/achievements/1) | |
| # * 2. an endpoint to SHOW a User (GET /v1/users/1) | |
| # * 3. an endpoint to GRANT an Achievement to a user (???) | |
| # EXAMPLE GEMFILE THAT SHOULD WORK: |
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
| import { Controller } from "stimulus"; | |
| import consumer from "../channels/consumer"; | |
| export default class extends Controller { | |
| static targets = ["message"]; | |
| connect() { | |
| this.element[this.identifier] = this; | |
| consumer.subscriptions.create("NotificationChannel", { |
OlderNewer