Rolling with Rails, ( Revisited version ) question ?

Hi everyone,

I recently noticed that the Rolling with Rails tutorial has had an update...

It all went well, but at the stage where you delete either of the files 'category.rhtml' or 'recipe.rhtml' & rename the remaining one to application.rhtml I get stuck.

The recipie link shows OK so is clearly using the application.html but when I click on the new footer link 'Show all categories' I get an error: No such file or directory - C:/Documents and Settings/dave/user/ cookbook2/config/../app/views/layouts/category.rhtml

( If I put the category.rhtml file back - I don't get the error )

But the tutorial said that it will default to application.rhtml if category.rhtml does not exist ?

I'm sure I've followed every step, but it's got me stumped...

TIA - Dave Porter

Hi Dave,

Hope you don't mind a little probing. Never seen this one before.

Davo wrote:

The recipie link shows OK so is clearly using the application.html

The file should be named with an extension of '.rhtml', not '.html'. Is that just a typo above?

When you say 'the recipie link shows OK' do you mean the new footer shows up and clicking the 'Show all recipes" link works ok? But clicking the 'Show all categories' throws an error?

Also, would you double-check that application.rhtml is the only file in the app\views\layouts directory? It should be.

But the tutorial said that it will default to application.rhtml if category.rhtml does not exist ?

It will if it can find a file named application.rhtml in the app\views\layouts directory.

Let us know on the questions above.

Best regards, Bill

Hi Bill,

Thanks for responding...

Yes the html was just a typo and Yes application.rhtml does exists and Yes the recipe shows OK and the links in the footer are there and the recipe ones work but the category one ( show all categories ) throws the error:

Template is missing Missing layout C:/Documents and Settings/dave/user/cookbook2/config/../ app/views/layouts/category.rhtml

regards, Dave

Hi Bill ( and anyone interested ! )

I noticed you said application.rhtml should be the only file in layouts folder.

I did have two other files there: category.old & application.rhtml.bak

So I moved them out of there & guess what - it now works OK.

I would love to hear an explanation on this - I would have assumed that because the application.rhtml was the only rhtml file there, that should have been sufficient, but clearly not !

regards, Dave

Hi Dave.

Davo wrote:

I noticed you said application.rhtml should be the only file in layouts folder.

I did have two other files there: category.old & application.rhtml.bak

This info is key. Thank you for documenting it. More below.

So I moved them out of there & guess what - it now works OK.

I would love to hear an explanation on this - I would have assumed that because the application.rhtml was the only rhtml file there, that should have been sufficient, but clearly not !

I've been thinking about this for a couple of hours now and I honestly don't know yet whether to call it a bug in Rails or something we just need to warn folks about. Here's my thinking so far. I'd appreciate any input.

1) link_to takes a url as its target. 2) a url is a path into a web domain that ultimately resolves to a file path on a server 3) a url is parsed right to left 4) a file path is parsed left to right

So the question, I think, is: what can we reliably use to trigger the switch in a parser from a url-based approach to a file-system-based approach?

The double dot notation you used on the file name is now perfectly valid file path notation for Windows file systems. It's also perfectly valid url notation. The parser has to decide where the file path ends and the url starts.

My gut feel at this point is that this should be called a Rails 'bug'. OTOH, it could just as easily be called an inescapable artifact of the transition we're in the middle of from a 'local' file system based model to a web based model of data locations. I never thought about this before but I'm not sure there's really any reliable way to tell the difference. I need some sleep, more thought, and some other's input before I'd be ready to take a position. In the meantime, I think you'd definitely be doing the Rails community a service by updating the O'Reilly site with your findings.

Thanks for the thought-provoking find.

Best regards, Bill

P.S. I'm glad you got un-stuck too. Welcome aboard!

Hi Bill,

Thank you for your thoughts...

& yes I have already asked the same questions on the tutorial, but will post a follow up with the findings...

regards, Dave