edit this page - page history - about editing

Ruby on Rails

  1. Rake
  2. Google OAuth2 with Ruby on Rails
  3. Using Capybara with Minitest for Integration Tests in Rails 4
  4. Loading seeds.rb data into test database through rake test
  5. Installing capybara-webkit on Ubuntu
  6. Enabling Jenkins support with Ruby on Rails tests
  7. Testing reports with Rails 4 and Minitest (just follow the instructions as is)

How I learnt Ruby on Rails

Following the Getting Started guide:
  1. Don't install the Cygwin version of Ruby or Ruby-rails. They will not work because I think cygwin paths get in the way of generating temporary files for Javascript compilation: Error: Cannot find module 'C:/cygdrive/c/DOCUME~1/Jevon/LOCALS~1/Temp/execjs20140124-6456-ws3la8.js' (in /usr/lib/ruby/gems/1.9.1/gems/turbolinks-2.2.0/lib/assets/javascripts/turbolinks.js.coffee)
  2. Install Ruby 1.9.3 from the Windows Installer package
  3. Install the Ruby 1.9.3 devkit: download the executable, extract it somewhere, follow the install instructions
  4. Install rails: gem install rails

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

On Windows, this error occurs because the Ruby on Rails install does not come with a server certificate package. As per this StackOverflow answer:
  1. Download http://curl.haxx.se/ca/cacert.pem into C:Railscacert.pem
  2. Go to your Computer -> Advanced Settings -> Environment Variables
  3. Create a new System Variable: SSL_CERT_FILE=C:Railscacert.pem
Close all your command prompts, including your rails server, and open up a new irb command prompt to test that it works:

$irb> require 'open-uri'
$irb> open('https://www.gmail.com')

Partial not rendering

Make sure you use <%= render 'form' %>, not the non-printing form without equals <% render 'form' %>. I'm guessing this is a different render to render text: in a controller.

Adding a new database field after generation

Initial generation of a database table:

rails generate model User openid_identity:string created_at:date name:string
rake db:migrate

Adding a new field 'last_login':

rails generate migration add_last_login_to_users last_login:date
rake db:migrate

Could not find generator monban:scaffold

The generators were moved into a separate Gem, monban-generators - add this to your Gemfile.

RuntimeError: @controller is nil: make sure you set it in your test's setup method.

Are you trying to write an integration test in test/integration/foo_test.rb? Make sure that you are using ActionDispatch::IntegrationTest as your test superclass, rather than ActionController::TestCase:

require 'test_helper'

class FooTest < ActionDispatch::IntegrationTest
  def setup

Loading additional autoload paths

In your config/application.rb (note everything within app/**/* should be autoloaded anyway!):

    # load additional paths
    config.autoload_paths += Dir["#{config.root}/custom/services/**/"]

Running a single Rspec file

$ rspec spec/games/playable_spec.rb --require rails_helper

edit this page - what links to here? - page history - top
Last edited by jevon jevon 20 months ago