bogdan / datagrid

Gem to create tables grids with sortable columns and filters
MIT License
1.02k stars 115 forks source link

Filter->Default Warning : :default as a Symbol is now treated as a method name. Use String instead or -> { default } if you really want default value to be a Symbol but not a String. #254

Closed jamesst20 closed 5 years ago

jamesst20 commented 5 years ago

Hi,

I was wondering if it could be fixed. When using default parameter in filter(), I get this warning:

:default as a Symbol is now treated as a method name. Use String instead or -> { default } if you really want default value to be a Symbol but not a String.

Edit: Sorry for the title, I did not notice the error was this long

Thank you

bogdan commented 5 years ago

You should change default: :something to default: :something.to_s or default: -> { :something }.

jamesst20 commented 5 years ago

That doesn't fix it sadly

bogdan commented 5 years ago

Can you show me the minimal code that produces the warning?

jamesst20 commented 5 years ago

Sorry for the late response

  describe "GET #index" do
    it "returns a success response" do
      create :cipc_check
      get :index, params: {}
      expect(response).to be_successful
    end
  end
class CipcChecksGrid < ApplicationGrid
  scope { CipcCheckBase }

  ...

  filter(:scope_filter, :enum, select: scopes(:active_or_recent, :processable, :unprocessable, :archived, :discarded),
         header: t("helpers.scopes.title"), default: :active_or_recent, include_blank: false) do |value, scope|
    scope.send(value)
  end
end

where scopes method is

def self.scopes(*scopes)
    lambda do
        scopes.each_with_object({}) do |elem, acc|
        acc[I18n.t("helpers.scopes.#{elem}")] = elem
        end
    end
end
Randomized with seed 3542
:default as a Symbol is now treated as a method name. Use String instead or -> { default } if you really want default value to be a Symbol but not a String.

1 example, 0 failures, 1 passed

Finished in 0.315739499 seconds
jamesst20 commented 5 years ago

@bogdan

I can see you removed the warning here https://github.com/bogdan/datagrid/commit/bd54295b5e7476a86113c317a6c980a8cd5a2f82

Is there a chance you can make a release?

Thank you

bogdan commented 5 years ago

v1.5.9