2

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.

Constantin Jacob
  • 488
  • 1
  • 8
  • 21

1 Answers1

1

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'
richsinn
  • 1,341
  • 1
  • 12
  • 27
  • just used the regular URL after firing up the WeBrick. localhost:3000 – Constantin Jacob Apr 16 '14 at 21:34
  • Also. localhost:3000/welcome/index doesn't work either. Same error – Constantin Jacob Apr 16 '14 at 21:35
  • Looking at your directory: `"/Users/Constantin/Development/Rails [Ruby]/new-app/app/views"` <~ does this mean you have a folder titled `"Rails [Ruby]"` with square brackets in your development machine? If so try removing the square brackets in your folder name (and then stop and restart your webrick server). – richsinn Apr 16 '14 at 21:51