Ransack: Form builder broken in Rails 5.2

Created on 14 Dec 2017  路  7Comments  路  Source: activerecord-hackery/ransack

Hi all,

On the 5.2.0beta branch of rails this line

https://github.com/activerecord-hackery/ransack/blob/724d020442dad60a1a6d9e00bbae7681350c9fb1/lib/ransack/helpers/form_builder.rb#L9

fails as value isn't called with any arguments from rails tag methods, eg:

https://github.com/rails/rails/blob/659c516bef2781cc66865fc78ed5dce682566d26/actionview/lib/action_view/helpers/tags/base.rb#L53

object is available here, so shouldn't need to be passed as an arg:

https://github.com/rails/rails/blob/659c516bef2781cc66865fc78ed5dce682566d26/actionview/lib/action_view/helpers/tags/base.rb#L10

so the change should be easy, but I can't figure out how to bundle ransack against rails 5.2.0beta to fix the specs. Any guidance and I'd be happy to help out with a PR :grin:

Most helpful comment

I'm experiencing this also on Rails 5.2.0.beta2 - in my request specs that call a template with a form_for I keep experiencing this error:

Failure/Error: <%= f.text_field :first_name, class: "form-control" %>

     ActionView::Template::Error:
       wrong number of arguments (given 0, expected 1)

When I downgrade to rails 5.1.4 or remove the ransack gem from the project this spec runs fine.

It's only when I pass in invalid params like this:

context 'invalid data' do
    it 'shows errors' do
      get edit_user_url(user)
      put user_url(user), params: { user: { email: '' } }
      expect(controller.flash[:alert]).to eq("Email can't be blank")
    end
end

Tried to pull from the polyamorous_1.3.2 branch but that didn't seem to help.

All 7 comments

@ttrmw This is part of a series of problems related to Rails 5.2, particularly I posted this problem here already: https://github.com/activerecord-hackery/ransack/issues/849#issuecomment-351026690

In order to keep everything in one place and avoid confusion, I suggest this issue be closed.

You may however gladly try to fix it with a pull request! :)

I can't figure out how to bundle ransack against rails 5.2.0beta to fix the specs

Can you be more specific? What did you try, where are you stuck?

Try this branch for adding any fixes to. https://github.com/activerecord-hackery/ransack/pull/858

I'm experiencing this also on Rails 5.2.0.beta2 - in my request specs that call a template with a form_for I keep experiencing this error:

Failure/Error: <%= f.text_field :first_name, class: "form-control" %>

     ActionView::Template::Error:
       wrong number of arguments (given 0, expected 1)

When I downgrade to rails 5.1.4 or remove the ransack gem from the project this spec runs fine.

It's only when I pass in invalid params like this:

context 'invalid data' do
    it 'shows errors' do
      get edit_user_url(user)
      put user_url(user), params: { user: { email: '' } }
      expect(controller.flash[:alert]).to eq("Email can't be blank")
    end
end

Tried to pull from the polyamorous_1.3.2 branch but that didn't seem to help.

Encountered the same issue on Rails 5.2.0.beta2

wrong number of arguments (given 0, expected 1)

Trace: https://gist.github.com/cdesch/91c7b74bee06fe274bcb499beae8e42a

Still within Rails 5.2 RC1. I am sure everyone is aware of that though. Any update on progress? Is this a priority?

@bbonislawski has PR open for fixes for this.

https://github.com/activerecord-hackery/ransack/pull/859

I created a merge commit but I can't get travis CI to understand which activerecord gem to use (specs pass locally).

Merge fork:
https://github.com/spark-solutions/ransack/pull/1

@corinnekunze Fantastic news! We are going to move forward with 5.2 RC1 due to our project release is quite a ways out and the ActiveStorage has already made life easier. Hopefully, the PR will be merged soon.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mkalmykov picture mkalmykov  路  3Comments

ivanovaleksey picture ivanovaleksey  路  3Comments

seanfcarroll picture seanfcarroll  路  4Comments

seanfcarroll picture seanfcarroll  路  3Comments

itsalongstory picture itsalongstory  路  3Comments