Coder Social home page Coder Social logo

fields_for about bootstrap_form HOT 6 CLOSED

bootstrap-ruby avatar bootstrap-ruby commented on July 24, 2024
fields_for

from bootstrap_form.

Comments (6)

carloslopes avatar carloslopes commented on July 24, 2024

@galulex where is this in the bootstrap docs?

Show me and i will take a look to implement it.

from bootstrap_form.

potenza avatar potenza commented on July 24, 2024

@carloslopes Until this past week, I had never used fields_for in any of my projects with this Gem. However, this week I used it for a nested association and ran into an problem that took me a while to figure out. I'm wondering if @galulex ran into the same issue. Here it is:

Say you have a user with a has_one association with an address model. If you do this:

bootstrap_form_for(@user) do |f|
  f.fields_for :address do |af|
    af.text_field(:street)
  end
end

AND you don't have accepts_nested_attributes_for :address set on the user model, you'll get an exception that looks something like this:

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.errors
    /Users/potenza/Sites/bootstrap_form/lib/bootstrap_form/form_builder.rb:69:in `control_group'
    /Users/potenza/Sites/bootstrap_form/lib/bootstrap_form/form_builder.rb:24:in `block (2 levels) in <class:FormBuilder>'
...

I'll commit a test case for this functionality shortly...

from bootstrap_form.

carloslopes avatar carloslopes commented on July 24, 2024

lol, i forgot the rails' fields_for helper and i was thinking that it was something of the bootstrap framework 😜

@potenza why did you use form_for on the test case? I updated the it to use bootstrap_form_for instead.

from bootstrap_form.

potenza avatar potenza commented on July 24, 2024

@carloslopes Oops! Stupid cut and paste error on my part. Thanks for catching that 😄

from bootstrap_form.

potenza avatar potenza commented on July 24, 2024

@galulex I'm gonna close this issue for now, but please let us know if you're running into a different issue with fields_for.

from bootstrap_form.

galulex avatar galulex commented on July 24, 2024

Thanks guys. Well done

ok

from bootstrap_form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.