Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,22 +316,15 @@ run Rack::Cascade.new [API, Web]

### Rails

Place API files into `app/api`. Rails expects a subdirectory that matches the name of the Ruby module and a file name that matches the name of the class. In our example, the file name location and directory for `Twitter::API` should be `app/api/twitter/api.rb`.

Modify `application.rb`:

```ruby
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we should leave this for older versions? Maybe just make sections

#### Rails 5.2 or Newer
...

#### Rails 4.0

?

config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
```
Place API files into `app/api`. Rails expects a subdirectory that matches the name of the Ruby module and a file name that matches the name of the class. In our example, the file name location and directory for `Twitter::API` should be `app/api/twitter/api.rb`. API changes in development will be picked up automatically.

Modify `config/routes`:

```ruby
mount Twitter::API => '/'
```

See [below](#reloading-api-changes-in-development) for additional code that enables reloading of API changes in development.
For Rails < 5.2, See [below](#reloading-api-changes-in-development) for additional code that enables reloading of API changes in development.

### Modules

Expand Down Expand Up @@ -3412,7 +3405,9 @@ Use [grape-reload](https://github.com/AlexYankee/grape-reload).

### Reloading in Rails Applications

Add API paths to `config/application.rb`.
In Rails >= 5.2, reloading should work without any modification.

For Rails <5.2, add API paths to `config/application.rb`.

```ruby
# Auto-load API and its subdirectories
Expand Down