Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 5 API support #376

Closed
ivanjolic95 opened this issue Jan 3, 2016 · 28 comments
Closed

Rails 5 API support #376

ivanjolic95 opened this issue Jan 3, 2016 · 28 comments

Comments

@ivanjolic95
Copy link

Are there any plans to support Rails 5 API? The problem with it is that API controllers don't have helper_method. One solution would be to inherit gem's EmberController from a special EmberController (or whatever the name is) in app that inherits ActionController::Base instead of ActionController::API. Right now it inherits ApplicationController which is an API controller in Rails 5 API. I've configured ember-cli-rails to support testing the gem on Rails 5.0.0.beta1 locally so I can make it work that way.

@ivanjolic95
Copy link
Author

The other solution would be to add a note in readme to make ApplicationController inherit ActionController::Base when using Rails 5 API.

@seanpdoyle
Copy link
Contributor

@ivanjolic95 thanks for opening this issue.

I'm unfamiliar with most of the changes coming in Rails 5, so I'm having trouble following your suggestions.

Are you saying that when you rails new --api, your app's ApplicationController extends from ActionController::API instead of ActionController::Base?

@ivanjolic95
Copy link
Author

Yeah, that's right.

@ivanjolic95
Copy link
Author

And if you try to use this gem with it, there's an error because helper_method is not defined for the ActionController::API

@KirillSuhodolov
Copy link

@ivanjolic95 @seanpdoyle I updated my project with rails 5 beta 1. I am using full rails(not only API) and I get 500 standard error instead of ember application and nothing in server logs.
It looks like ActionController::Base really doesn't have helper_method too

@ivanjolic95
Copy link
Author

@KirillSuhodolov it's working for me when I use ActionController::Base. Which version of ember are you using?

@CollinGraves
Copy link

If anyone is following this issue and needs ember-cli-rails support with a Rails 5 build, feel free to use my fork of this repository (updated for use with Rails 5) until this gets straightened out. I'll keep it as current as possible.

Thoughts on this going forward, @seanpdoyle? Would love to send a patch through to you.

seanpdoyle added a commit that referenced this issue Feb 2, 2016
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.

Closes [#376].

[#376]: #376
[rails]: https://github.com/rails/rails
@seanpdoyle
Copy link
Contributor

#400 attempts to fix this issue.

seanpdoyle added a commit that referenced this issue Feb 2, 2016
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.

Closes [#376].

[#376]: #376
[rails]: https://github.com/rails/rails
seanpdoyle added a commit that referenced this issue Feb 2, 2016
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.

Closes [#376].

[#376]: #376
[rails]: https://github.com/rails/rails
seanpdoyle added a commit that referenced this issue Feb 2, 2016
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.

Rails 5 depends on `rack@2.0.x`, 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`.

Closes [#376].

[#376]: #376
[rails]: https://github.com/rails/rails
seanpdoyle added a commit that referenced this issue Feb 2, 2016
Closes [#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 `rack@2.0.x`, 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`.

[#376]: #376
[rails]: https://github.com/rails/rails
seanpdoyle added a commit that referenced this issue Feb 2, 2016
Closes [#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 `rack@2.0.x`, 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`.

[#376]: #376
[rails]: https://github.com/rails/rails
@seanpdoyle
Copy link
Contributor

@CollinGraves @ivanjolic95 @KirillSuhodolov #400 supports Rails 5.0.0.beta2.

Would you mind seeing if it resolves your issues?:

# Gemfile

gem "ember-cli-rails", github: "thoughtbot/ember-cli-rails", branch: "sd-rails-5"

Unfortunately, Rails 5 depends on rack@2.0.x, which depends on >= ruby@2.2.2.

Dropping support for older Rubies constitutes a breaking change, and according to semantic versioning will require a major bump (in our case, a minor bump since the project is pre 1.0.x).

This will delay the release of Rails 5 support. Before we introduce a breaking change, I'd like to wait until the stable release of Rails 5 (i.e. no -beta).

Does that sound reasonable?

seanpdoyle added a commit that referenced this issue Feb 8, 2016
Closes [#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 `rack@2.0.x`, 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`.

[#376]: #376
[rails]: https://github.com/rails/rails
@makabde
Copy link

makabde commented Feb 10, 2016

@seanpdoyle I have tried your above solution, using the sd-rails-5 branch with a newly generated Rails 5 API application, and a newly generated ember application. When booting the Rails app with either bin/rails s or be rails s the index page stays blank, but I have the following console output

=> Booting Puma
=> Rails 5.0.0.beta2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma 2.16.0 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:3000
Started GET "/" for ::1 at 2016-02-10 15:54:58 +0100
Processing by EmberCli::EmberController#index as HTML
  Parameters: {"ember_app"=>:client}
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)

I have followed the setup instructions and did not customize any view since the base Rails app is an API only configured Rails app.

@seanpdoyle
Copy link
Contributor

@makabde thanks for the additional information.

Just to clarify, in your application, ApplicationController < ActionController::API?

the index page stays blank

Could you share the HTML that is returned? Processing by EmberCli::EmberController#index as HTML gives me reason to believe that you're getting some sort of HTML response.

Are there any 404 responses in your browser's network tab?

@makabde
Copy link

makabde commented Feb 10, 2016

@seanpdoyle yes, that right.

@seanpdoyle
Copy link
Contributor

@makabde thanks!

the index page stays blank

Could you share the HTML that is returned? Processing by EmberCli::EmberController#index as HTML gives me reason to believe that you're getting some sort of HTML response.

Are there any 404 responses in your browser's network tab?

@makabde
Copy link

makabde commented Feb 10, 2016

@seanpdoyle I created a repo so that you can maybe clone it and try yourself. So far both, the Rails and the Ember app are new but I would still expect to see the "Welcome to Ember", if everything was working as expected.

https://github.com/makabde/tapp

Also some screenshots of the returned HTML and of the browsers network tab.
screen shot 2016-02-10 at 16 39 57
screen shot 2016-02-10 at 16 40 10

@seanpdoyle
Copy link
Contributor

The sd-rails-5 branch should now support your use case, with some side-effects that might be unfortunately unavoidable.

@makabde Please see this new commit.

@makabde
Copy link

makabde commented Feb 10, 2016

@seanpdoyle The application now runs as expected, with this new commit. Do you think you will be able to come up with a solution that you will somehow prevent those side-effect you were referencing in the commit.

On the other hand would you recommend sticking to a "regular" Rails app with a dedicated controller for the API that will inherit from ActionController::API; in order to avoid those potentially annoying side effects?

@seanpdoyle
Copy link
Contributor

@makabde this commit attempts to avoid < ActionController::Base by:

  • inheriting from ApplicationController
  • re-including modules into EmberCli::EmberController that are in ActionController::Base, but not in ActionController::API

This feels like an awful idea, but is effective in leveraging application-wide controller logic shared in ApplicationController.

@makabde
Copy link

makabde commented Feb 11, 2016

👍

@quezacoatl
Copy link

I get the following error:

ActionView::Template::Error (undefined method `render_ember_app' for #<#<Class:0x00000003a43438>:0x00000003ae0f08>):
    1: <%= render_ember_app params[:ember_app] do |head| %>
    2:   <% head.append do %>
    3:     <%= csrf_meta_tags %>
    4:   <% end %>

even when using sd-rails-5 branch. I'm using rails/master too. It works if I change to < ActionController::Base, but then I don't see any point in the sd-rails-5 branch. Any other solutions?

cdunn pushed a commit to cdunn/ember-cli-rails that referenced this issue Mar 17, 2016
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 `rack@2.0.x`, 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
seanpdoyle added a commit that referenced this issue Apr 22, 2016
Closes [#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 `rack@2.0.x`, 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`.

[#376]: #376
[rails]: https://github.com/rails/rails
@williamweckl
Copy link

Any updates?

@undergroundwebdesigns
Copy link

undergroundwebdesigns commented Jun 28, 2016

FYI, to those interested, I've just submitted #466 which fixes the "undefined method 'render_ember_app'" error and gets the branch sd-rails-5 working as expected on Rails 5 rc2.

@williamweckl
Copy link

Rails 5 launched and ember-cli-rails does not support it... :(

ember-cli-rails was resolved to 0.7.4, which depends on
railties (< 5, >= 3.2)

@undergroundwebdesigns
Copy link

@williamweckl My fork https://github.com/undergroundwebdevelopment/ember-cli-rails/tree/sd-rails-5 is working for me, and includes the railties dependency bump.

@williamweckl
Copy link

@undergroundwebdesigns ty :)

seanpdoyle added a commit that referenced this issue Jul 8, 2016
Closes [#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 `rack@2.0.x`, 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`.

[#376]: #376
[rails]: https://github.com/rails/rails
seanpdoyle added a commit that referenced this issue Jul 8, 2016
Closes [#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 `rack@2.0.x`, 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`.

[#376]: #376
[rails]: https://github.com/rails/rails
@hauleth
Copy link

hauleth commented Jul 17, 2016

What is status of this? Rails 5 is now stable.

@seanpdoyle
Copy link
Contributor

Hi @hauleth!

We've made some serious progress on Rails 5 support in this PR, but we're currently blocked by some JRuby test failures.

We could use some help, as I don't have any personal experience with JRuby.

Once those tests are passing, we'll be able to merge and release Rails 5 support.

@hauleth
Copy link

hauleth commented Jul 17, 2016

@seanpdoyle seems like this is related to RVM and JRuby in general, not to this gem jruby/jruby#2496.

seanpdoyle added a commit that referenced this issue Aug 10, 2016
Closes [#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.

**Improve `setup_ember` script**

* 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

**Fix `EmberCli::EmberController` inheritance**

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

**Depend on `test-unit`**

```
Ruby 2.2+ has removed test/unit from the core library. Rails requires
this as a dependency. Please add test-unit gem to your Gemfile:
`gem 'test-unit', '~> 3.0'` (cannot load such file -- test/unit)"
```

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

Rails 5 depends on `rack@2.0.x`, 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`.

[#376]: #376
[rails]: https://github.com/rails/rails
seanpdoyle added a commit that referenced this issue Aug 10, 2016
Closes [#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.

**Allow JRuby failures in CI**

**Improve `setup_ember` script**

* 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

**Fix `EmberCli::EmberController` inheritance**

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

**Depend on `test-unit`**

```
Ruby 2.2+ has removed test/unit from the core library. Rails requires
this as a dependency. Please add test-unit gem to your Gemfile:
`gem 'test-unit', '~> 3.0'` (cannot load such file -- test/unit)"
```

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

Rails 5 depends on `rack@2.0.x`, 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`.

[#376]: #376
[rails]: https://github.com/rails/rails
@seanpdoyle
Copy link
Contributor

closed by #400

Samsinite pushed a commit to Samsinite/ember-cli-rails that referenced this issue Mar 10, 2020
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.

**Allow JRuby failures in CI**

**Improve `setup_ember` script**

* 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

**Fix `EmberCli::EmberController` inheritance**

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

**Depend on `test-unit`**

```
Ruby 2.2+ has removed test/unit from the core library. Rails requires
this as a dependency. Please add test-unit gem to your Gemfile:
`gem 'test-unit', '~> 3.0'` (cannot load such file -- test/unit)"
```

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

Rails 5 depends on `rack@2.0.x`, 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
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

No branches or pull requests

9 participants