Skip to content

Instantly share code, notes, and snippets.

@Justinwceo
Justinwceo / _form.html.erb
Created July 30, 2011 22:39
WORKING CODE: Reverse Jquery TokenInput ( How to get a many-many association working on the form when using the "authorships" form instead)
<%= form_for(@user_product) do |f| %>
# This line is the virtual attribute base on a product_id and then the "data-pre" maps to my ProductsController/Application.js for the /products.json route.
# Its for seeing the Product on the Edit form, it has to be found.
<%= f.text_field :product_token, "data-pre" => @products.map(&:attributes).to_json %>
<%= f.label :price %><br />
<%= f.text_field :price %>
<%= f.submit %>
<% end %>