views:

46

answers:

3

I like how Rails gives me flexibility in naming view files, ie index.erb or index.html.erb essentially do the same thing.

The problem is that I've merged two separate projects, where one uses filename.erb for all its views and the other uses filename.html.erb.

It seems that Rails expects only one naming scheme as I keep getting missing template errors for the views with only the .erb extension.

Can I get around this? Should I even want to get around this? Or should I bite the bullet and manually rename half of my view files?

A: 

You should stick with the more modern rails convention of *.html.erb.

Ryan McGeary
That's what we decided to do, however Rails is still expecting only `.erb` and is still throwing template missing errors. Is there some setting I can change to explicitly tell Rails how to look for templates?
A: 

Are you using different versions of Rails? Rails versions below 2.0 wouldn't support the .html.erb format.

floyd
nope. tried this on both 2.3.3 and 2.3.5. same issues with both.
+1  A: 

To me it sounds like there may be a problem with the naming conventions you're using.

See what happens when you choose an action that isn't working and then explicitly try and render a template with:

render :template => 'products/show'

Where 'products/show' is the path to your layout in the views directory. If that doesn't work it might help locate the issue.

Another thing to try is to use the format declaration from within your action:

respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @products }
end

The docs here are also very explicit about how the conventions by which docs are found. http://guides.rubyonrails.org/layouts_and_rendering.html

Hope that helps, David

dtt101
thanks, I'll definitely take a look at that and report back!