{"action":"created","issue":{"url":"https://api.github.com/repos/nathanvda/cocoon/issues/286","labels_url":"https://api.github.com/repos/nathanvda/cocoon/issues/286/labels{/name}","comments_url":"https://api.github.com/repos/nathanvda/cocoon/issues/286/comments","events_url":"https://api.github.com/repos/nathanvda/cocoon/issues/286/events","html_url":"https://github.com/nathanvda/cocoon/issues/286","id":70428202,"number":286,"title":"Name of local variables through two partials","user":{"login":"allenwlee","id":1839288,"avatar_url":"https://avatars.githubusercontent.com/u/1839288?v=3","gravatar_id":"","url":"https://api.github.com/users/allenwlee","html_url":"https://github.com/allenwlee","followers_url":"https://api.github.com/users/allenwlee/followers","following_url":"https://api.github.com/users/allenwlee/following{/other_user}","gists_url":"https://api.github.com/users/allenwlee/gists{/gist_id}","starred_url":"https://api.github.com/users/allenwlee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenwlee/subscriptions","organizations_url":"https://api.github.com/users/allenwlee/orgs","repos_url":"https://api.github.com/users/allenwlee/repos","events_url":"https://api.github.com/users/allenwlee/events{/privacy}","received_events_url":"https://api.github.com/users/allenwlee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-23T14:35:11Z","updated_at":"2015-04-23T15:33:56Z","closed_at":null,"body":"I don't know if this is a cocoon issue, but I found that my form doesn't work if I use a custom variable (in my case, `pt`) instead of `f`.  I am passing down locals through an embedded partial because I had read somewhere that the name of the `fields` partial is important.  The code below works:\r\n###### models (just showing Ticket)\r\n```\r\nclass Ticket < ActiveRecord::Base\r\n  has_many :goods_tickets\r\n  has_many :goods, through: :goods_tickets\r\n  has_many :services_tickets\r\n  has_many :services, through: :services_tickets\r\nend\r\n```\r\n###### tickets/new.html.erb\r\n```\r\n@product_types = ['Good'.constantize, 'Service'.constantize]\r\n```\r\n###### new.html.erb\r\n```\r\n<%= form_for @ticket do |ticket| %>\r\n    <% @product_types.each do |p| %>\r\n       <%= ticket.fields_for \"#{p.name.downcase}s_tickets\".to_sym do |pt| %>\r\n           <%= render \"#{p.name.downcase}s_ticket_fields\", { pt: f, product_type: p } %>        \r\n       <% end %>\r\n       <%= link_to_add_association \"Add a #{p.name}\", ticket, \r\n           \"#{p.name.downcase}s_tickets\".to_sym, \r\n           render_options: { locals: { product_type: p } }, class: 'btn btn-default' %>\r\n    <% end %>\r\n<% end %>\r\n```\r\n###### _goods_ticket_fields.html.erb\r\n`<%= render 'ticket_fields', { f: f, product_type: product_type } %>`\r\n###### _services_ticket_fields.html.erb\r\n`<%= render 'ticket_fields', { f: f, product_type: product_type } %>`\r\n###### _ticket_fields.html.erb\r\n```\r\n<%= f.fields_for product_type.name.downcase.to_sym do |p|  %>\r\n      <%= p.select \"#{product_type.classification_name.downcase}_id\", \r\n              options_for_select(@classes), { include_blank: @placeholder}, \r\n              { class: \"search-item form-control menu-select2\" } %>  \r\n      <label for=\"product-name\"><%= product_type.name %> Name*</label>\r\n      <%= p.text_field :name, \r\n            { class: \"form-control #product_type.classification_name.downcase}-name\", \r\n              placeholder: \"Type in the name of your service, e.g., 'Pacific Cod'\" } %>\r\n<% end %>\r\n```\r\n\r\nbut if i replace `f` in line 3 of `new.html.erb` with `pt`, and adjust all the references accordingly, I get the following error:\r\n```\r\nShowing .../app/views/tickets/_goods_ticket_fields.html.erb where line #1 raised:\r\n\r\nundefined local variable or method `pt' for #<#<Class:0x007ffd940cabb8>:0x007ffd934c2208>\r\nExtracted source (around line #1):\r\n1\r\n              \r\n<%= render 'ticket_fields', { f: pt, product_type: product_type } %>\r\n\r\nTrace of template inclusion: app/views/tickets/new.html.erb\r\n```\r\n "},"comment":{"url":"https://api.github.com/repos/nathanvda/cocoon/issues/comments/95626689","html_url":"https://github.com/nathanvda/cocoon/issues/286#issuecomment-95626689","issue_url":"https://api.github.com/repos/nathanvda/cocoon/issues/286","id":95626689,"user":{"login":"nathanvda","id":34460,"avatar_url":"https://avatars.githubusercontent.com/u/34460?v=3","gravatar_id":"","url":"https://api.github.com/users/nathanvda","html_url":"https://github.com/nathanvda","followers_url":"https://api.github.com/users/nathanvda/followers","following_url":"https://api.github.com/users/nathanvda/following{/other_user}","gists_url":"https://api.github.com/users/nathanvda/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanvda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanvda/subscriptions","organizations_url":"https://api.github.com/users/nathanvda/orgs","repos_url":"https://api.github.com/users/nathanvda/repos","events_url":"https://api.github.com/users/nathanvda/events{/privacy}","received_events_url":"https://api.github.com/users/nathanvda/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T15:33:56Z","updated_at":"2015-04-23T15:33:56Z","body":"Wait: the rest of your explanation does not make sense? I see no definition of `f` in the `new.html.erb`, only `pt`. :confused:"}}