views:

45

answers:

1

Hi all.

I'm a happy user of RoR but have one complaint. When I do script/generate scaffold it automatically generates all my files and places them in their proper folders. However, all the different scaffolds I've created name their view files the same.

I have a bunch of index.html.erb view files and when I have them open in my text editor, it's almost impossible to tell what controller they're related to.

I'd like to change the default naming scheme of the scaffold command to name the individual files to contain their view folder name. So, instead of index.html.erb, use index.home.html.

Is there a way to do this, or am I stuck? What solutions to the multiple files with the same name problem have you Rails developers discovered?

Thanks!

+1  A: 

You're going to be fighting the Rails' conventions by going down that path and Rails works best when you work with it rather than against it. A core part of the philosophy of Rails is that there are a set of conventions that once learned make it easy to find your way around any Rails application.

Instead of trying to redefine how Rails works, I would recommend taking advantage of the features offered by your text editor or IDE for quickly navigating to the correct view template. For example, the Rails bundle within TextMate on the Mac lets you quickly open the view file associated with a particular model and there's a plugin for Vim that provides an equivalent feature.

John Topley
John and I think the same... in Textmate, press in Command+T and you'll be able to see index.html.erb for Users/Projects/Whatever. The HTML in the "index.html.erb" is the content-type, so I recommend not trying to change that.
Jesse Wolgamott
I discovered that I can rename my views to index.html.home.erb and not run into any issues. However, is there a way I could make render ignore everything after the first period so that I could do index.home.erb?
Michael
I'm currently using MacRabbit's Espresso as my editor and it doesn't have the switch to view feature that Textmate has. However, when there are two files open with the same name, it also shows the folder they're located in. I just wish it did that all the time for views...
Michael