question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question about recommended way to access a controller from a route given `no-controller-access-in-routes` rule

See original GitHub issue

Accessing this.controllerFor() property inside setupController/resetController method in a route class raises a lint error ( no-controller-access-in-routes). Is that the expected behavior and if yes, how can one access another controller in a route class.

I am accessing the controller to setup route transition redirect like this (I could opt to use query params or disable the lint on the affected LOC but is there an option to access another controller in a route)

Screenshot_from_2021-03-09_14-32-38

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
roommancommented, May 18, 2021

Also hitting up against this: the rule and the Ember guides for Storing and Retrying Transitions are at odds. 🙃

5reactions
doska80commented, Jul 5, 2021

I am upgrading ember from version 3.20 to 3.24.

The no-controller-access-in-routes rule recommends not using a controller within a route, unless the reference to the controller is in the setupController/resetController hooks, as can be seen in the link below:

https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-controller-access-in-routes.md

However we have some willTransition actions that access the controller, and even the ember documentation, there is an example of willTransition accessing the controller, as can be seen in the link below:

https://api.emberjs.com/ember/3.26/classes/Route/events/willTransition?anchor=willTransition

this eslint rule is correct? If the app needs access to the controller from willTransition, how to handler this question?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Question about recommended way to access a controller from ...
Question about recommended way to access a controller from a route given `no-controller-access-in-routes` rule.
Read more >
Exception is raised when 2 controller routes and a named ...
Exception is raised when 2 controller routes and a named action route is used. i have this webapi controller: using Microsoft.AspNetCore.
Read more >
MVC route rule to default to Home controller when no ...
The simplest option is to use static URLs in your route config, like ContactUs rather than using {action} (which can literally match anything)....
Read more >
Express Tutorial Part 4: Routes and controllers - MDN Web Docs
The code first imports the Express application object, uses it to get a Router object and then adds a couple of routes to...
Read more >
Rails Routing from the Outside In - Ruby on Rails Guides
How to construct your own routes, using either the preferred resourceful style or ... How to declare route parameters, which are passed onto...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found