I am modifying a Ruby Rails application – Redmine. I want to modify a function that renders a partial preview. In the view I believe this is accomplished via
<%= render :partial => 'documents/form' %>
I need to modify the function this is attached to.
Where might I look for this?
Is render the function I am looking for?
Is :partial a parameter? What does the => operator do?
I do realize learning Ruby and Rails would solve these issues, but for the current situation I just need to know enough to make a small tweak. I know it’s not in the controller.
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
rendermethod, which is part of Rails itself, as some of the other answers have suggested.The
rendermethod 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 syntaxrender :partial => "documents/form"is Ruby’s way of passing keyword arguments to method; it is essentially just saying to renderdocuments/formas a partial template. (In Ruby, this is actually equivalent torender({:partial => "documents/form"}), which is just invoking methodrender, 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 inapp/views, you will probably be looking forapp/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.