ransack searching each word in a text_field - ruby-on-rails

I will searching with ransack in my Rails application for users by firstname and lastname. In one text_field for firstname and one text_field for lastname the application user should have the possibility to search for several parts of the name.
E.g. the user will enter "Thomas Jeffrey" and this should results in:
SELECT FROM users WHERE firstname LIKE "%Thomas%" AND firstname LIKE "%Jeffrey%";
If I use firstname_cont the result looks like:
SELECT FROM users WHERE firstname LIKE "%Thomas Jeffrey%";
When I was trying firstname_cont_all out, I got something different.
Thank you for any hint.

User.search(firstname_cont_all: params[:my_field].split)
I do not know, however, how to properly introduce that splitting to array when using ransack's condition_field form builder utility.

Related

Search URL on the new LinkedIn UI

Looks like LinkedIn has a new UI and seems to be slowly rolling out to everyone. We have a LinkedIn button on our site that looks up a prospect by their name and company and searches LI. Currently, this works for the "oldLinkedIn" but for me, I'm somehow on the "nuLinkedIn" and this search URL doesn't render properly. Our current search URL for oldLinkedIn will populate this: http://www.linkedin.com/search/fpsearch?company=salesforce&fname=carden&lname=wyckoff&currentCompany=C For me, this loads a blank page with just the LinkedIn logo, but for another employee still on the oldLinkedin it renders properly and can see the client. When I do a manual search for this person in nuLinkedIn, this is the URL https://www.linkedin.com/search/results/index/?keywords=carden%20wyckoff%20salesforce&origin=GLOBAL_SEARCH_HEADER we are trying to figure out what the new URL search query is so we can update our search button for linkedin. Thanks!
If you change your populated URL to:
https://www.linkedin.com/search/results/index/?keywords=firstname%3A"carden"%20AND%20lastname%3A"wyckoff"%20AND%20company%3A"salesforce"&origin=GLOBAL_SEARCH_HEADER
it should work.
Obviously you can use OR instead of AND in there for more results.
Fields you can search are:
firstname: Finds members based on first name
lastname: Finds members based on last name
title: Finds members based on their current title
company: Finds members based on their current company (keyword search)
school: Finds members based on schools attended (keyword search)

Retrieve Specific Value In Firebase

I have a list of users in Firebase that looks like this...
How would I retrieve only the email (for example) values?
THE answer.
Two things.
1) Please copy and paste your structure instead of a picture so we don't have to retype it. Please take a minute to format it so it looks cool.
2) This is a very basic query in Firebase and fully explained in the Most Excellent Guide to Retrieving Data In Firebase
Scroll down the query section and there are a couple of examples that are very similar to what you are asking for.
And a tad more info. Doing a query will retrieve each child node that matches the query (including the other stuff within the node). It's up to your code to grab each email (pretty simple task as it's key:value pairs)
If you don't want the other stuff, you would need to change the structure of the data
asdf
firstName
lastName
etc
emails
asdf
email: email address
asdf1
email: email address
or, use events: value for example and a structure like this
emails
asdf: email address
asdf1: email address

Extract the content of text to be used in a Zapier action

Can someone please help with a code that will extract a name from a text. I am trying to create an action in a Zapier that will extract the Firstname and Lastname from a gmail. I've tried to modify the "Simple Email Extraction" example given here https://zapier.com/help/code/#introductory-examples , but need someone to point me in the right direction. The example gmail will look like this:
Navn: Firstname Lastname
Adresse: Streetadress
PostNr/Sted: Postalcode City
E-post: emailadress
Mobil: mobilephone
What I need to extract is the content of "Firstname Lastname" into an output that can be used in the action.
the Zapier email parser suggested by Matt solved this problem.

Handling order of names in languages like Chinese

In numerous places in my app, I have a name displayed (current user or other user). I have 3 fields for name: firstName, lastName and fullName. Full is simply firstName + lastName, and not used very often. I use 'firstName lastName' more often than fullName.
I recently localized the app into other languages, among them Chinese and Japanese, in which the order for names is reversed to 'lastName firstName'.
I am unsure how to handle this change now in my app. Has anyone encountered a similar challenge and how did you handle it?
Thank you
I figured out how to do this by saving a string called fullName in my Localizable Strings file as follows:
"fullName" = "%1$# %2$#";
Then, in the languages that have the name order different, their "fullName" string is like this:
"fullName" = "%2$# %1$#";
Hope this is helpful to someone else! :)

Foursquare API : Is there any way to search venue with name and city?

Using Foursquare API is there any way to search venue with name and city?
currently I am using parameter "query" to search venue, how can I pass city name along with venue name to get exact results
I want to search restaurant located in specific city
FSQ API Current Search query which is working for restaurant name search only:
https://api.foursquare.com/v2/venues/search?ll=40.744010080453,-73.985651532083&categoryId=4d4b7105d754a06374d81259&query=starbucks&client_id=your_client_id&client_secret=your_client_secret
In above search query I have used "query=starbucks" to search restaurant "starbucks"
Any one knows how to do search with name and city for venue?
Please help...
You can replace the ll parameter with near and put a city name in there, for example
https://api.foursquare.com/v2/venues/search?near=new york, ny&categoryId=4d4b7105d754a06374d81259&query=starbucks&client_id=your_client_id&client_secret=your_client_secret
I am finding that for place names comprising of two or three words the use of an an underscore works for example:
near=New_York
or
near=Playa_Del_Carmen
near=Hong_Kong
Reason being in a browser a space becomes the characters '%20', however when passing a GET string value to a url such as from a search box or via PHP I found that the string being passed with spaces was not being "read/interpreted" correctly. Adding the underscore seems to resolve that issue.

Resources