Haiyuan Zhang
Haiyuan Zhang

Reputation: 42792

rails render question

My question is about rails rendering rule. if the the following line of code

render "intentions"

appears in a rails app, how do you interpret it? my understanding is that rails will try to find an action named intentions, and find the action's template file named intentions.html.erb under the current controller's view directory, and finally render it.

but in my caee, in a 100% working app, there is no action named intentions under the current controller. but there is a template file named _intentations.html.erb under current controller's view directory and it is this template finally be rendered.

what kind of rendering rule it is? I need a explanation. thanks in advance.

Upvotes: 0

Views: 122

Answers (1)

Austin Lin
Austin Lin

Reputation: 2564

Rails automatically looks through your views when rendering to see if any match. If you are calling render from within a view it looks for a partial view, which is defined by a underscore as the first character in its name.

Upvotes: 2

Related Questions