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
Expose target action in req object #1372
Comments
I think you should close this issue. It's not an issue, but a proposal. |
Don't close it and add a label then, would be better! |
@Vadorequest Issues are for issues. Discussions are for google groups. Stack overflow is more of an "FAQ" thing. |
Google group is a fucking bullshit thing. Absolutely useless, just the fact 2014-02-07 14:20 GMT+01:00 Wesley Overdijk notifications@github.com:
Cordialement, M. Ambroise Dhenain. |
I'm opting out of this conversation. But watch your language. |
according to the contributors requests via CONTRIBUTING.md new features should be requested on Trello.. not github. https://github.com/balderdashy/sails/blob/master/CONTRIBUTING.md |
Good to know, thanks. 2014-02-08 16:54 GMT+01:00 Mike DeVita notifications@github.com:
Cordialement, M. Ambroise Dhenain. |
Thanks @mikedevita, @RWOverdijk, and @Vadorequest! @marionebl
Re: your suggestion-- I'm on board with splitting Thanks for bringing this up! |
Thanks Mike! I'm still using the 0.9.8 version and I won't use the 0.10 until it's So, whatever there is a bueprint or not, I think that it would be better to 2014-02-10 2:38 GMT+01:00 Mike McNeil notifications@github.com:
Cordialement, M. Ambroise Dhenain. |
Thank you for the insight on the reasoning behind To clear things up on this issue: Just like @Vadorequest said the actual problem for me was that requests hitting blueprints don't receive an action key in That's perfectly logical taking the way Closing this issue. |
I use sails 0.10 rc2 and
is missing both action and controller information no matter what blueprint route I hit. The only usefull value is the model. It was easier to write policies in sails 0.9x. |
@artworkad I came up with a simple utility method that derives the target action from the request object. Have a look at my answer on SO: http://stackoverflow.com/a/21683181/3263412. Getting the controller can safely be done via: |
@marionebl thanks, but sails complains about
It cannot find the module. Any ideas on this? |
You'll have to install |
@marionebl Got it, I can get controller but your service returns undefined for the action :/ |
So this works for me now. E.g. there is an action book on the ticket model:
but not absolutely secure ... :/ |
Hey, I guess you could get detailed help (from more devs!) via IRC (irc.freenode.org, channel #sailsjs). Contribution Guide | Stackoverflow | Google Group | Trello | IRC |
@Vadorequest @marionebl thanks for taking the time to explain, guys. I'm on the same page now. And you're right. |
@marionebl the service you put together on Stackoverflow helps a lot I'll play with it for a bit and see if we can make it simpler to grab hold of the relevant information. If anyone has any ideas in the meantime, let me know! |
@mikermcneil I updated my sails app (https://github.com/balderdashy/sails-docs/issues/242#issuecomment-52510987) and couldn't find how to fix this, I just saw that it's available from Maybe this change should also be documented in the doc that explains what changed from 0.9.x to 0.10.x! |
Some news about how to get action and controller? :'( |
@luqezman |
@RWOverdijk this options is only available after "route" middleware runs :'( Inside a hook using "after route" listener, is impossible to get it 👎 |
I'm not familiar with the after route listener, so I can't help. |
The
req.target
object was removed on the road to v0.10 (discussed here, commit 409f744) and replaced byreq.options
.This is all nice looking at it from the hooks and configuration side, but the options object does not contain information about the target action (formerly
req.target.action
) the request will land on, e.g.exposes not enough information to get the target action in a sane way. That makes it really hard to write solid policies or views that need to know about the target action without mimicking a big part of the sails router logic (read: I was not able to find one).
Now to what this boils down is the following proposal: Expose the target action in the request object again, e.g. like this:
Related SO question: stackoverflow.com/../get-sails-request-target-from-policy-scope
Related Google Groups posting: https://groups.google.com/forum/#!topic/sailsjs/faX54hqcNZE
The text was updated successfully, but these errors were encountered: