sportngin/okcomputer — pull request #42 by johnnyshields (2014-04-07 20:30:18+00:00)
Title: Refactor OKComputer routes into an engine, and isolate its namespace

I've refactored to better use Rails' engine related features. Previously, OKComputer was mounting mounting its routes directly into Rails. It's nicer if we mount it instead as an engine (see change in `/config/routes.rb`)

You'll now see this in `rake routes`:

```
Routes for OKComputer::Engine:
root GET|OPTIONS / ok_computer/ok_computer#show {:check=>"default"}
all GET|OPTIONS /all(.:format) ok_computer/ok_computer#index
GET|OPTIONS /:check(.:format) ok_computer/ok_computer#show
```

**Caveat**

It's a best practice to use `isolate_namespace` on engines (see http://guides.rubyonrails.org/engines.html), which means you namespace your controllers. However for some reason I don't understand, Rails doesn't seem to like the namespace `OKComputer`, and I've had to add the following:

```ruby
# in lib/okcomputer.rb
OkComputer = OKComputer

# in spec/spec_helper.rb
require OKComputer::Engine.root.join("app/controllers/o_k_computer/ok_computer_controller")
```

Alternatives to this are:

1) Change the gem's namespace to `OkComputer` with a lowercase 'k' (magically fixes above issue). You can see this at commit https://github.com/johnnyshields/okcomputer/commit/18830ffc1cadcd0db9423999f2aefac2c2108fdc

2) Remove `isolate_namespace`