Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Hagen Volpers's Profile

GitHub User: hvolpers

Comments by Hagen Volpers

Avatar

Hi,

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.

Avatar

Hi,

I missed the as option to create the helper:

ruby
get "/posts/:id/page/:page", to: 'posts#show', as: post_page
resources :posts

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).

Regards,
Hagen

Avatar

Hi,

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?

ruby
[...]
get "/posts/:id/page/:page", to: 'posts#show'
resources :posts
[...]

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 ...

Regards,
Hagen

Avatar

Hi,

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 :)

Regards,
Hagen