bradigan
(bradigan)
November 25, 2011, 12:50am
1
To note, I only have the URI in a string as its from a POST from an
external API as JSON Data.
Basically I need this:
http://www.someapp.com/events/12345
I just need the 12345
Obviously, params[:id] won't work so I'm not sure how to get this. I
tried this:
url = data['referring_site']
event_id = CGI::parse(URI::parse(url).query)
But it didn't work.
Where the referring_site was the URL in question.
Thanks
Brad
Is there anything wrong with:
data[‘referring_site’].split(“/”).last
Which will give you what you are looking for, assuming that is the limit of your URL?
bradigan
(bradigan)
November 25, 2011, 3:09am
3
Beauty!!!! Thats it.
Thank you.
Knew it was a string call, just not sure which one. Especially coming
from the PHP world.
Thanks again.
B
11155
(-- --)
November 28, 2011, 11:51am
4
bradigan wrote in post #1033619:
To note, I only have the URI in a string as its from a POST from an
external API as JSON Data.
Basically I need this:
http://www.someapp.com/events/12345
For what it's worth, a request to that URL should be sent using the HTTP
PUT method. If I'm not mistaken Rails should then automatically provide
"12345" in params[:id].
But, the provided solutions should work for your needs.