Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Short alias for long compound search field #253

Closed
estum opened this issue Jul 15, 2013 · 7 comments
Closed

Short alias for long compound search field #253

estum opened this issue Jul 15, 2013 · 7 comments

Comments

@estum
Copy link

estum commented Jul 15, 2013

I have search field with very long parameter name: user_bill_info_fullname_or_user_bill_info_phone_or_user_bill_info_address_cont. How to create short alias for it, �eg bill_info?

@gamov
Copy link

gamov commented Jul 16, 2013

Can't you just store it in a variable?

@estum
Copy link
Author

estum commented Jul 16, 2013

I've �already did so… I would like to see it in pretty url with GET params.�

@AndreySavelyev
Copy link

+1
I need this feature too.

@radar
Copy link
Contributor

radar commented Sep 4, 2013

If you people need this feature then the best way to get it in would be to submit a patch for it.

@AndreySavelyev
Copy link

I found solution.
There is don't need alias.
You can use ransacker
In my case, in Person model


ransacker :full_name do |parent|
      Arel::Nodes::InfixOperation.new(
        '||', parent.table[:first_name_ru],
        Arel::Nodes::InfixOperation.new(
          '||', parent.table[:last_name_en],
          Arel::Nodes::InfixOperation.new(
            '||',
            parent.table[:first_name_en],
            parent.table[:last_name_ru]
          )
        )
      )

and if the form


= search_form_for @q do |f|
  = f.text_field :full_name_cont, placeholder: t('.search')

@estum
Copy link
Author

estum commented Sep 4, 2013

AndreySavelyev, awesome! Thanks.

@jonatack
Copy link
Contributor

Added with #623.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants