bootstrap-ruby / bootstrap_form

Official repository of the bootstrap_form gem, a Rails form builder that makes it super easy to create beautiful-looking forms using Bootstrap 5.
MIT License
1.64k stars 352 forks source link

Undefined method `name' for "Search":Ransack::Name #546

Closed daniel-g closed 2 years ago

daniel-g commented 4 years ago

When using a ransack object, there's an error trying to get the model name's name:

https://github.com/bootstrap-ruby/bootstrap_form/blob/aa2cb2933cd655bb0ebf1e9691b28760f8a77054/lib/bootstrap_form/components/hints.rb#L23-L27

The workaround is setting the help text manually:

= f.text_field :nombre_cont, help: ""
lcreid commented 4 years ago

Thanks for reporting this issue. I haven't used Ransack, so it will take time for me to research the problem. If you have an open source project that reproduces the problem, a link to it would help me a lot. Also, feel free to submit ideas for a fix, or a pull request to fix the problem.

I noticed that the Ransack documentation has specific instructions for using SimpleForm. If you have a chance, please try following the instructions for SimpleForm, but where it says to put ::SimpleForm::FormBuilder, put ::BootstrapForm::ActionViewExtensions::FormHelper? (And if your bootstrap_form_for uses the builder option, remove it for this test.)

Thanks again for taking the time to report this issue.

harada4atsushi commented 4 years ago

@lcreid @daniel-g Hi, Nice to meet you.

I implemented like #549 , How is it?

lcreid commented 4 years ago

@daniel-g Could you please try the fix in @harada4atsushi 's pull request and see if that resolves your issue? I think you would put something like this in your Gemfile:

gem "bootstrap_form", git: "https://github.com/harada4atsushi/bootstrap_form.git", branch: "support-ransack-object"

Then bundle install and run whatever you used to test before.

daniel-g commented 4 years ago

@harada4atsushi @lcreid it works great :) thanks for the effort :D