Skip to content

Conversation

@undergroundwebdesigns
Copy link

Adds logic to conditionally load extra controller modules and manually include the EmberCLI helper when inheriting from an ApplicationController that inherits from ActionController::API instead of ActionController::Base. Allows the gem to work as expected with Rails 5 apps that use the --api option when generating the app.

seanpdoyle and others added 6 commits April 22, 2016 10:55
Closes [tricknotes#376].

Required changes
----------------

Run test suite against the latest `5.0.0.betaX` and `master` branches of
[`rails/rails`][rails].

Since `EmberController` extends `ApplicationController`, which can now
extend from either `ActionController::Base` (which implements
`helper_method`) and `ActionController::API` (which doesn't implement
`helper_method`), we can't depend on that API existing.

Remove call to `helper_method` from `EmberController`, as it is no
longer supported.

Support changes
---------------

Rails 5 depends on `[email protected]`, which **requires** Ruby `2.2.2` or
greater.

In order to support Rails 5, we will no longer support versions of Ruby
prior to `2.2.2`.

[tricknotes#376]: tricknotes#376
[rails]: https://github.com/rails/rails
* Don't overwrite `gemfiles/` changes with `appraisal install`
* Localize Ember setup to `bin/setup_ember`
* Always invoke, let `bin/setup_ember` decide whether or not to no-op
The `EmberCli::EmberController` used to inherit from
`ApplicationController` in order to reap the benefits of
application-wide configurations and behavior (such as
authentication-based `before_action` calls and other macros).

Unfortunately, with the introduction of Rails 5's `rails new --api`,
applications' `ApplicationController` can now inherit from
[`ActionController::API`][api], which doesn't serve HTML by default.

To support Rails 5's default `--api` behavior,
`EmberCli::EmberController` must inherit from `ActionController::Base`,
forcing the controller to forfeit all the benefits of sharing behavior
with `ApplicationController`.

[api]: http://edgeapi.rubyonrails.org/classes/ActionController/API.html
Adds logic to conditionally load extra controller modules and manually include the EmberCLI helper when inheriting from an ApplicationController that inherits from ActionController::API instead of ActionController::Base.
# ).each do |mod|
# include mod
# end
unless self.ancestors.include? ActionController::Base

Choose a reason for hiding this comment

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

Redundant self detected.

@williamweckl
Copy link

+1

@seanpdoyle seanpdoyle force-pushed the sd-rails-5 branch 2 times, most recently from 4227314 to 8838c07 Compare July 8, 2016 18:36
@seanpdoyle seanpdoyle force-pushed the sd-rails-5 branch 3 times, most recently from ceed542 to 876720b Compare August 10, 2016 15:08
@seanpdoyle
Copy link
Contributor

Closing in favor of #400.

If you think this shouldn't be closed, please comment and I'll reopen.

@seanpdoyle seanpdoyle closed this Aug 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants