Skip to content

Instantly share code, notes, and snippets.

@trev
Created January 27, 2016 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trev/ffff644f22f0cfdbcb9b to your computer and use it in GitHub Desktop.
Save trev/ffff644f22f0cfdbcb9b to your computer and use it in GitHub Desktop.
= simple_form_for @form, wrapper: :booking do |f|
.simple-group
%h3.small-title Your Personal Information
= f.simple_fields_for :line_items do |li|
= li.simple_fields_for :passengers do |pax|
.row
.col-md-12
%h4= "Trip: #{Product.find(li.object.product_id).title}"
%h5= "Tell us about dude ##{pax.index + 1}"
= pax.input :first_name, placeholder: 'Big'
= pax.input :last_name, placeholder: 'Lebowski'
= pax.input :email, placeholder: 'thedude@yourdudeness.com.au'
= pax.input :phone_number, placeholder: '+61 410 394 323'
= pax.input :dob, label: "Date of birth", placeholder: 'dd/mm/yyyy'
= f.button :submit
@apotonick
Copy link

class YourForm < ..
  def product
    Find bla whatever product_id
  end
end

@trev
Copy link
Author

trev commented Jan 27, 2016

@apotonick doing something like:

class YourForm < Reform::Form
  def product
    Product.find(self.product_id)
  end
end

Will result in getting the following error:

*** ArgumentError Exception: A copy of YourForm has been removed from the module tree but is still active!

Works fine if you do ::Product.find(self.product_id) to jump out of the local scope.

Comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment