given: @url = "http://localhost:3000/esb/ID-
swordfish-27243-1327514975752-13-85879"
@searchPattern = /(ID-swordfish-(\d+-)(\d+-)(\d+-)(\d+))/
with: Ruby 1.9.2 or greater
when: @searchPattern =~ @url
then: $1 = "ID-swordfish-27243-1327514975752-13-85879"
Individual results may vary!
Cheers,
SC
On Feb 16, 3:48 am, Naira Kobo
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> Hi Folks,
>
> I have this path configured in my html.rb file:
>
> <td><%= link_to traces_by_original_exchange.short_exchange_id,
> list_trace_by_short_exchange_id_path(traces_by_original_exchange.short_exch
ange_id)
> %></td>
>
> and this in my route.rg file
>
> match ''esb/list_trace_by_short_exchanges'' =>
> ''esb#list_trace_by_short_exchanges'', :as =>
> :list_trace_by_short_exchange_id
>
> the link above generates a path:
>
> http://localhost:3000/esb/list_trace_by_short_exchanges.ID-swordfish-...
>
> However in my controller:
> I need to be able to retrieve
> "ID-swordfish-27243-1327514975752-13-85879"
>
> I have the listing below (in my controller):
>
> def list_trace_by_short_exchanges
> @traces_by_short_exchanges = TblTrace.find_by_sql("select top (1) *
from
> tbl_traces
> where short_exchange_id = ''" + params[:id] +
"'' order by created_on
> desc")
>
> respond_to do |format|
> format.html # show.html.erb
> format.json { render :json => params[:id] }
> end
> end
>
> How do I retrieve that value?
>
> Note that I had tried:
>
> <td><%= link_to traces_by_original_exchange.short_exchange_id,
> traces_by_original_exchange.short_exchange_id %></td>
>
> but the url turns out to be
>
> http://localhost:3000/esb/ID-swordfish-27243-1327514975752-13-85879
>
> but I need the url to be:
>
> http://localhost:3000/esb/list_trace_by_short_exchanges/ID-swordfish-...
>
> or atleast get that parameter:
>
> ID-swordfish-27243-1327514975752-13-85879
>
> in the function list_trace_by_short_exchanges in ym controller.
>
> What is the best way to do this?
>
> --
> Posted viahttp://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.