RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: hvolpers
that was one thing I didn't get - I was missing the action in the application controller.
However, you shouldn't use render here - you limit yourself. The way Ryan is doing it here gives you the opportunity to "overwrite" the template by putting another version of the template into the specific controllers view directory.
I missed the as option to create the helper:
get "/posts/:id/page/:page", to: 'posts#show', as: post_page
So calling post_page_path(@post, 2) now generated the link /posts/1/page/2 as expected.
But would be great to know how pagination handles that (or if I missed something else in the cast).
kind of off-topic, but I try to figure out how to use the route manually without using pagination. Is it pagination figuring out if it has to add the page number as get parameter or as ressource?
get "/posts/:id/page/:page", to: 'posts#show'
I wasn't able to figure out how to make the link_to helper to use of the new route (in this episode it looks like pagination does the "magic"?!).
I don't like hard wired links, so perhaps someone can help me out, I already tried post_url(@post, page: 2), but that leads to the expected /posts/1?page=2 ...
post_url(@post, page: 2)
no. 2 shouldn't be an issue as long as content is generated via the page itself - the one creating the content will also regenerate the cache :)