A proof of concept of having Sinatra like routes inside your controllers.
Since the router is gone, feel free to remove config/routes.rb.
Then add the file below to lib/action_controller/inline_routes.rb
inside your app.
| # Yockeries - Yaml + Mocks + Factories(easy way to create them) | |
| # | |
| # Long ago there was an uprising against YAML fixtures in the rails world. Some | |
| # people replaced them with things like FactoryGirl, Machinist, Fabrication, and a | |
| # bunch of others. | |
| # | |
| # However, YAML is still the simpliest thing that works, because it comes with | |
| # Ruby. When you load in a yaml file with YAML.load_file, the yaml data is | |
| # converted into a hash, which again is simple to use and test. You can take | |
| # that hash and create a new object with it: Person.new(yaml_converted_hash), |
| class PostsController < ActionController::Base | |
| def create | |
| Post.create(post_params) | |
| end | |
| def update | |
| Post.find(params[:id]).update_attributes!(post_params) | |
| end | |
| private |
| #! /bin/sh | |
| # file: /usr/bin/ruby | |
| # | |
| # the normal 'rbenv global 1.9.3-p0' will affect this script but, unlike having *only* rbenv, this ruby will be available at low run levels (aka, for init scripts) | |
| export RBENV_ROOT="/usr/local/rbenv" | |
| export PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH" |
| module ObjectDiagnostics | |
| extend self | |
| #This is handy when you want to determine what types of objects are contributing to memory bloat | |
| #returns the change in object counts since the last time this method was called | |
| def change_in_object_counts | |
| #this will start all counts at 0 for the initial run | |
| @previous_counts ||= Hash.new(0) |
| module Sequel | |
| module Plugins | |
| # The paranoia plugin creates hooks that automatically set deleted | |
| # timestamp fields. The field name used is configurable, and you | |
| # can also set whether to overwrite existing deleted timestamps (false | |
| # by default). Adapted from Timestamps plugin. | |
| # | |
| # Usage: | |
| # | |
| # # Soft deletion for all model instances using +deleted_at+ |
| #!/usr/bin/env ruby | |
| #gem_cmd = ENV["GEM_CMD"] || 'sudo gem' | |
| gem_cmd = 'gem' | |
| STDIN.map { |l| l.strip }.each { |l| | |
| gem, versions = l.split(' ', 2) | |
| versions = versions.gsub(/[\(\)]/, '').split(', ') | |
| versions.each { |version| | |
| cmd = "#{gem_cmd} install #{gem} -v #{version} --no-ri --no-rdoc" |
| ## Prepare ################################################################### | |
| # Remove RVM | |
| rvm implode | |
| # Ensure your homebrew is working properly and up to date | |
| brew doctor | |
| brew update | |
| ## Install ################################################################### |
| Key was generated using: | |
| tom% openssl genrsa -des3 -out example.com.key 2048 | |
| Generating RSA private key, 2048 bit long modulus | |
| ....+++ | |
| ..........................................................................................................................+++ | |
| e is 65537 (0x10001) | |
| Enter pass phrase for example.com.key: | |
| Verifying - Enter pass phrase for example.com.key: | |
| %tom |
| # RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
| # defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
| module Player | |
| describe MovieList, "with optional description" do | |
| it "is pending example, so that you can write ones quickly" | |
| it "is already working example that we want to suspend from failing temporarily" do | |
| pending("working on another feature that temporarily breaks this one") |