"Missing Template" when manually creating views

Hi everyone,

I am trying to set up a controller and a view manually, without the
aid of scaffolding (though I am using a scaffolded model as reference).

I have set up my controller like this:

class RecetasController < ApplicationController
def index
respond_to do |format|
format.html #index.html.erb
end
end
end

I have created a single file named index.html.erb inside
app/views/receta. So far in only has a few HTML lines. When I access
http://localhost:3000/recetas, I get this message on my browser:

“Missing template recetas/index.erb in view path app/views”

What gives? Scaffolded models generate .html.erb files and they work
right! So I go ahead and change my view to be named index.erb. I still
get the same error message! What am I missing?

tuti plain wrote:

Hi everyone,

I am trying to set up a controller and a view manually, without the
aid of scaffolding (though I am using a scaffolded model as reference).

I have set up my controller like this:

class RecetasController < ApplicationController
def index
respond_to do |format|
format.html #index.html.erb
end
end
end

I have created a single file named index.html.erb inside
app/views/receta. So far in only has a few HTML lines. When I access
http://localhost:3000/recetas, I get this message on my browser:

“Missing template recetas/index.erb in view path app/views”

What gives? Scaffolded models generate .html.erb files and they work
right! So I go ahead and change my view to be named index.erb. I still
get the same error message! What am I missing?

Could you please give the log printed in the webrick ?

Actually I faced this error during the time of placing wrong code inside
environment.rb file.

Thanks

Hello,

I believe folder which holds views for recetas controller must be
named in plural: recetas
…from your post i can see that its in singular: “I have created a
single file named index.html.erb inside
app/views/receta.”

On Sun, Mar 21, 2010 at 8:56 PM, tuti plain [email protected]
wrote:

 format.html #index.html.erb

What gives? Scaffolded models generate .html.erb files and they work
right! So I go ahead and change my view to be named index.erb. I still
get the same error message! What am I missing?

Hi, you’ll need to rename the ‘receta’ folder to ‘recetas’.

Good luck,

-Conrad

Hi,

Thanks, you were right, renaming the folder solved the problem. I
think I’ll never fully understand the plurals and singulars in Rails.
What I don’t get is why the scaffolded model has its views named like
.html.erb but my manually created one has to be .erb only. I have no
problem in doing it like that, but I’d like to understand why it is.

Thanks again.

I have created a single file named index.html.erb inside
app/views/receta.
As the message says, it should be app/views/recetas

On 22 March 2010 11:54, tuti plain [email protected] wrote:

Hi,

Thanks, you were right, renaming the folder solved the problem. I
think I’ll never fully understand the plurals and singulars in Rails.
What I don’t get is why the scaffolded model has its views named like
.html.erb but my manually created one has to be .erb only. I have no
problem in doing it like that, but I’d like to understand why it is.

They do not have to be named .erb only. Rails looks for a range of
names, one of which is .erb, the error message can be confusing.
.html.erb is the recommended way for html generated by erb.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs