There are a few ways to get this done.
Passing params to Batman.redirect
Calling @redirect
handles the controller before/afterActions, then delegates to Batman.redirect
.Batman.redirect
can take:
- a string, which is treated as the target URL (
"/posts"
) - a Batman.Model, which redirects to the index (
Batman.redirect(MyApp.Post)
redirects to"/posts"
) - a Batman.Model instance, which redirects to "show" (
Batman.redirect(thisPost)
redirects to"/posts/#{thisPost.id}"
*) - an object containing params:
Batman.redirect({controller: "posts", action: "index"})
=>/posts
Batman.redirect({controller: "posts", action: "edit", id: 6})
=>/posts/6/edit
* Actually calls record.toParam?() || record.get('id')
to get the param
So, you could use @redirect({controller: "posts", action: "index"})
or @redirect(App.Post)
to redirect to the index action.
Using a NamedRouteQuery
I'm not great with NamedRouteQuery, but here are some examples anyways:
App.get('routes').posts().path()
=>/posts
App.get('routes').posts(6).path()
=>/posts/6
App.get('routes').posts().get(6).path()
=>/posts/6
App.get('routes').posts().get(6).get('edit').path()
=>/posts/6/edit
You could use one of those to get your url string, then pass the string to @redirect
.
Hope this helps!