Pregunta

I'm a newbie with Ruby on Rails and I know that it is kind of tricky but I just can't find a solution for this online, even though it is supposed to be the easiest thing...

I have everything set up and have created a new controller + view with rails generate controller welcome index .

The files appear in the correct directories and I have a index.html.erb file in the welcome folder under /app/views/welcome/.

The routing file in /config/ contains the appropriate routing to the controller

NewApp::Application.routes.draw do
  get "welcome/index"

  # You can have the root of your site routed with "root"
   root 'welcome#index'
end

But even though I have everything set up correctly to my knowing I get this error:

Missing template welcome/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. 
Searched in: * "/Users/Constantin/Development/Rails [Ruby]/new-app/app/views"

I understand the error message. It tells me that it looks for some kind of template file in the named formats in the views folder of my application but I don't understand why it is not working.

¿Fue útil?

Solución

It seems like your project path for your rails app has has a folder with square brackets in the name (the folder titled Rails [Ruby]) :

/Users/Constantin/Development/Rails [Ruby]/new-app/app/views

Remove the square brackets from the folder name and restart your server.

For more information, check out this issue: Rails projects do not work if project path contains open bracket "["

Also change your get route to be like this:

get 'welcome/index' => 'welcome#index'
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top