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

Adds the ability to use starts_with and ends_with in string filters #1962

Conversation

rmw
Copy link
Contributor

@rmw rmw commented Mar 1, 2013

filter :title_starts_with, :as => :string
filter :title_ends_with, :as => :string

Fixes #1958

filter :title_starts_with, :as => :string
filter :title_ends_with, :as => :string

activeadmin#1958
@@ -15,7 +15,11 @@ def label_text
end

def input_name
"#{super}_contains"
method.to_s.match(metasearch_conditions) ? method: "#{method}_contains"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you're missing a space in that ternary operator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange that the tests didn't break ... but it's been fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably for the same reason that this works:

irb(main):001:0> true ? foo: 5
NameError: undefined local variable or method `foo' for main:Object

As in, the ternary operator has higher precedence in the Ruby parser.

macfanatic added a commit that referenced this pull request Mar 7, 2013
@macfanatic
Copy link
Contributor

Hmm, looks like issue didn't close automatically, but this was pulled in.

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

Successfully merging this pull request may close these issues.

Allow option to filter using starts_with or other meta_search filtering
3 participants