Klairvoyant infosolution's Blog

passing variables to the partial in rails

john

There is a bit of magic involved in passing variables to the partial. Because the partial is named “person,” the main template will look for an instance variable @person, and pass it to the partial as a local variable, person. What if the instance variable doesn’t match the name of the partial? Then you’d explicitly pass it, like this: “person”, :locals => { :person => @scott } %>All the key/value pairs in the :locals hash will be made into local variables for the partial.