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?
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
You should stick with the more modern rails convention of *.html.erb
.
Are you using different versions of Rails? Rails versions below 2.0 wouldn't support the .html.erb
format.
精彩评论