I'm trying to order or rank a contacts phone numbers in rails so that users can change the order of a phone number. I'm using the nested form gem if that helps.
The idea is that I want to rank them based the order in which they come in. so the user could move the phone number field up or down the list and then based on what position in the list the number is in, it would be ranked in that order.
so like it would be listed as
phone1
phone2
phone3
phone4
then the user could change the order to
phone2
phone4
phone1
phone3
and rails would know to re order them, ie,
change phone2's rank to phone1
phone 4's rank to phone2
etc.
I could change the order on the front end, but what that feels like there could be issues
thanks in advance
I'd run with something like https://github.com/swanandp/acts_as_list to manage the ranking stuff, but as far as the front-end goes, your best bet is to either use hidden form fields for the ordering (and update their values via JS), or each time a number is moved (via some sort of javascript goodness), submit that to a controller via xhr and re-render the list of numbers as a partial.
Related
I'm playing around with the Here.com autosuggest feature, and I'm trying to find a way to limit the results of a query to only cities. I only want it to return potential city, state/prov, country matches, and not addresses or specific places.
The use case here is to allow the user to start typing in their current city and have autosuggest fill out the rest. So in this case, I also can't send the query with a bounding parameter like at or in, since I want the search to allow for matches world wide.
Is this possible with the current implementation of autosuggest? Or is there another way to accomplish this?
Thanks!
The API itself doesn't allow you to limit based on city but you can select responses where localityType=city in your application.
For example Lets say you wanna store some phone numbers into the database. But you only want to accept the phone number if it starts with a certain area code. Lets say the area code is 123. I want to be able to accept/reject that phone number depending if it starts with 123 and don't care what comes after.
I know how to validate it using model validations, but its annoying to change the model validations once the area code gets much bigger in scale.
How would I validate the phone numbers by storing an area code into a database/using a database and then testing it against a new entry of a phone number?
Assuming in your application, there will be a settings/constant information to save information that are frequently changed. If,not you can create a key value pair general settings, where they key could be area code and the value 123.
Then you can use this to validate the phone no, this way if area code changes, all you have to do is update the value in general settings for key 'area_code'.
I need to build a search form including some fields like "city, price range, key word and date". I saw this video which is recommending to create a "searches" table. Every time any user made a search, it creates a table row in the db, and show the results depending on the submitted fields.
Seems easy to build but is it safe? I mean, if this is used in the practical world, I think we also have to use "I'm not robot" from Google.
https://www.youtube.com/watch?v=QRE7KxIvUb4&t=29s
Any idea is welcome.
I wanted to write a code to allow user to parse data, I know that the '&___' pops up an input box for user input. So what I was thinking was to allow users to enter the number of components, and then based on that another input box to allow users to enter the lengths of the substrs. for example
ABCD123LMNOP
number of component =3
substr1 =1,4
substr2=5,3
subtr3=8,5
and result would be 4 columns, one with the original string, and then the three columns with the 3 substrs.
table name= RAW_DATA
column name= Data_VALUE
I thought about using a loop based on the user input but I wasn't sure how to get the loop working, and also that using '&___' asks for all user input at once, please let me know if this is possible on PL/SQL Developer.
Thanks in advance.
I am using twitterizer in an ASP.NET-project. I nned an example (code) how I can use twitterizer to show a list of followers (paged) for a special account that don't follow back.
The query is: Give me all users that I follow for e.g. 5 days but that didn't follow me back. The result should be displayed in a GridView with paging.
Thanks!
As I stated in the email, there is no way to filter friends or followers by date.
Your best bet to do this is to use TwitterFriendship.FriendsIds() and TwitterFriendship.FollowersIds(), then select the difference between the two. That will give you the list of followers that you don't follow. (Friends are users you follow.) In order to identify new friends/followers, you'll need to keep a list of the Ids, then consult that list at a later date to see the changes over time.
You could create a database (or list, etc) of users you followed and users who follow you. Update this as often you you need and add a time stamp for each new addition. Then you could query this database to create the list you want.