I'm assuming that you would like to change the code for the partial itself, and just want to know where to find the template for that partial, not change the render
method, which is part of Rails itself, as some of the other answers have suggested.
The render
method tells Rails to render a particular template, possibly with some parameters passed in. A partial is a kind of template that is intended to render only a fragment of a page, such as an individual widget or a single section of the page. The syntax render :partial => "documents/form"
is Ruby's way of passing keyword arguments to method; it is essentially just saying to render documents/form
as a partial template. (In Ruby, this is actually equivalent to render({:partial => "documents/form"})
, which is just invoking method render
, passing in a hash table in which :partial
, a keyword, maps to "documents/form"
, a string).
So, the code that will actually be rendered is the partial documents/forms
. By convention, partials are loaded from files prefixed with _
; and if you're using the default ERb template format, then they will likely end in .html.erb
. As all view code is stored in app/views
, you will probably be looking for app/view/documents/_form.html.erb
. Yes, this is a not particularly obvious bit of convention, but that's Rails for you.
See the Rails Guide on partials and rendering for more information.