Reputation: 11
I am fairly new to rails and had a question.
I am wanting to direct my controller to point to the html.erb view i created.
I have tried various versions of:
def index
render :"viewName"
end
def index
render :viewName
end
def index
render : "viewName.html.erb"
end
My router is set as such:
Rails.application.routes.draw do
root 'application#index'
end
Upvotes: 1
Views: 51
Reputation: 2004
If you want to render a partial then
render partial: 'some_view'
or
render 'some_view'
this will look for a file _some_view.html.erb
If you want to render some template then
render template: 'template_name'
this will look for template_name.html.erb
Upvotes: 0
Reputation: 2290
You just need to follow the convention, if you're pointing it to the controller: Application
, action: Index
, then you need an "application" folder in your views, and a "index.html.erb" inside this application folder and you don't need to call any render inside the action.
So in this case create the following folder
/app/views/application
And inside it place your:
index.html.erb
On your application_controller.rb
def index; end
I wouldn't use application controller though...
Upvotes: 1