Reputation: 5
I just create a new rails project and try to add new page. i write rails g controller main index
, and its create only controller. I try to add in view a new folder named "main" and create file "index.html.erb", but when i try to see my page it just return nothing, a white page without html code
this is my main_controller.rb
class MainController < ApplicationController def index end end
this is my index.html.erb
<p>hello</p>
and this is my routes.rb
Rails.application.routes.draw do root 'home#index' end
Upvotes: 0
Views: 308
Reputation: 316
You need to use the correct route as your controller is named MainController so your route should be "main#index". Your route file should have this code
Rails.application.routes.draw do
root 'main#index'
end
Check if you have a HomeController and if you don't have maybe it's just cached as it's showing blank page try clearing the cookies and reloading the page. (Works for me most of the times.)
Upvotes: 1
Reputation: 447
You need to specify correct controller in your routes.rb
file which is MainController
, so it should look like this:
Rails.application.routes.draw do
root 'main#index'
end
Upvotes: 0