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

Route helper for resource is not created #1

Open
th0r opened this issue Feb 17, 2014 · 6 comments · May be fixed by #2
Open

Route helper for resource is not created #1

th0r opened this issue Feb 17, 2014 · 6 comments · May be fixed by #2

Comments

@th0r
Copy link

th0r commented Feb 17, 2014

I have the following resource:

this.resources('users', { only: ['index', 'edit', 'update', 'destroy'] });

So, I don't have page to view user information (users#show), but I do have page to edit it (users#edit) and action to update if (users#update).
The problem is that in this case the route helper userPath is not generated and I can't set action attribute of the user's edit form:

<form id="editUser" method="put" action="{{ userPath(user) }}">...</form>
@jaredhanson
Copy link
Owner

As noted in jaredhanson/locomotive#136, if you have a chance to fix this bug and issue a pull request, I'll merge it in.

@th0r
Copy link
Author

th0r commented Feb 17, 2014

@jaredhanson, I'm looking at this right now.
So, how do you want it to be fixed? The problem is that show route has optional format parameter, but create, update and destroy don't.
Do you want me to rename helpers to showResource, createResource, updateResource and destroyResource?

@jaredhanson
Copy link
Owner

I think any optional parameters should be handled gracefully if they aren't specified, so ideally that's a non issue. Helper names should not be changed.

@th0r
Copy link
Author

th0r commented Feb 17, 2014

I mean, if helpers for the create, update and destroy routes will be the same, as for show, then resourcePath(123, 'xml') will generate path /resource/123.xml, which will not be matched by create, update and destroy routes.

@jaredhanson
Copy link
Owner

What if you just write resourcePath(123)? I'm assuming your app will know its generating a URL for, say, the update route and then doesn't need specify the format argument.

@th0r
Copy link
Author

th0r commented Feb 17, 2014

Well...maybe you right and I'm a little paranoid =)

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 a pull request may close this issue.

2 participants