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

Setting consider_all_requests_local to true launches build_and_watch in non-dev environments #361

Closed
kayakyakr opened this issue Dec 16, 2015 · 4 comments

Comments

@kayakyakr
Copy link

This bit of code seems to default the environment to 'development' and overrides when consider_all_requests_local is set to true in other environments.

# /lib/ember_cli/helpers.rb

    def default_environment
      if Rails.env.test?
        "test"
      elsif Rails.env.production? || !rails_config_for(:consider_all_requests_local)
        "production"
      else
        "development"
      end
    end

This is particularly a gotcha in a staging environment which may be running requests as local. I don't know if it would be beneficial to remove that dependency, though. Have to watch that, as I had 4 build --watch instances running through various staging deploys.

It might be better to default to production for the ember env:

# /lib/ember_cli/helpers.rb

    def default_environment
      if Rails.env.test?
        "test"
      elsif Rails.env.development? || rails_config_for(:consider_all_requests_local)
        "development"
      else
        "production"
      end
    end
@seanpdoyle
Copy link
Contributor

@kayakyakr thanks for opening this issue after resolving your strange behavior.

I'm a little confused by your suggestion:

Rails.env.development? || rails_config_for(:consider_all_requests_local)

Wouldn't consider_all_requests_local be set to false in your staging environment (in the scenario you've explained). Wouldn't this cause ember build --watch to be executed?

This behavior should definitely be explained better -- I'll likely open a PR against the README.

What is your particular use case?

You want to treat your staging requests as local, while not running ember build --watch (i.e. precompiling assets up front and serving them)?

@kayakyakr
Copy link
Author

Hm, you're right, that doesn't really gain much. It actually just prioritizes consider_all_requests_local over environment.

Ideally, for me, anything that isn't development would come through as production, regardless of the state of consider_all_requests_local. The main purpose of that is to display rails server errors instead of generic errors, no?

Ember-cli doesn't have quite as much knowledge of dealing with non-standard environments as rails, from what I understand?

seanpdoyle added a commit that referenced this issue Dec 20, 2015
Closes [#361].

When the Rails environment is neither `test` nor `development` ([two
environments handled by EmberCLI out-of-the-box][ember-cli-env]), treat
it as `production`.

[#361]: #361
[ember-cli-env]: http://ember-cli.com/user-guide/#Environments
seanpdoyle added a commit that referenced this issue Dec 20, 2015
Closes [#361].

When the Rails environment is neither `test` nor `development` ([two
environments handled by EmberCLI out-of-the-box][ember-cli-env]), treat
it as `production`.

[#361]: #361
[ember-cli-env]: http://ember-cli.com/user-guide/#Environments
@seanpdoyle
Copy link
Contributor

@kayakyakr does #366 seem like reasonable behavior?

@kayakyakr
Copy link
Author

Looks good to me.

seanpdoyle added a commit that referenced this issue Dec 20, 2015
Closes [#361].

When the Rails environment is neither `test` nor `development` ([two
environments handled by EmberCLI out-of-the-box][ember-cli-env]), treat
it as `production`, unless an `EMBER_ENV` is specified.

[#361]: #361
[ember-cli-env]: http://ember-cli.com/user-guide/#Environments
seanpdoyle added a commit that referenced this issue Dec 20, 2015
Closes [#361].

When the Rails environment is neither `test` nor `development` ([two
environments handled by EmberCLI out-of-the-box][ember-cli-env]), treat
it as `production`, unless an `EMBER_ENV` is specified.

[#361]: #361
[ember-cli-env]: http://ember-cli.com/user-guide/#Environments
seanpdoyle added a commit that referenced this issue Dec 20, 2015
Closes [#361].

When the Rails environment is neither `test` nor `development` ([two
environments handled by EmberCLI out-of-the-box][ember-cli-env]), treat
it as `production`, unless an `EMBER_ENV` is specified.

[#361]: #361
[ember-cli-env]: http://ember-cli.com/user-guide/#Environments
seanpdoyle added a commit that referenced this issue Dec 20, 2015
Closes [#361].

When the Rails environment is neither `test` nor `development` ([two
environments handled by EmberCLI out-of-the-box][ember-cli-env]), treat
it as `production`, unless an `EMBER_ENV` is specified.

[#361]: #361
[ember-cli-env]: http://ember-cli.com/user-guide/#Environments
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

2 participants