Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
route :get, :delete, :post, :put, '/*/*?/?*?' do |model, action, id|
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
darthophage  
View profile  
 More options May 1 2012, 2:46 am
From: darthophage <darthoph...@sympatico.ca>
Date: Mon, 30 Apr 2012 23:46:57 -0700 (PDT)
Local: Tues, May 1 2012 2:46 am
Subject: route :get, :delete, :post, :put, '/*/*?/?*?' do |model, action, id|
route :get, :delete, :post, :put, '/*/*?/?*?' do |model, action, id|
  # some code
end

Then, when I navigate to http://localhost/something/something/something

puts model  # ="something"
puts action # =""
puts id # =""

I need to have the splats to collect anything written between / /
and also the optional ? commands for the splats and /

does the optional command splat's collection?
How do I do this properly?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Eduardo L. Lopes  
View profile  
 More options May 2 2012, 9:54 am
From: "Carlos Eduardo L. Lopes" <carlos.el.lo...@gmail.com>
Date: Wed, 2 May 2012 10:54:33 -0300
Local: Wed, May 2 2012 9:54 am
Subject: Re: route :get, :delete, :post, :put, '/*/*?/?*?' do |model, action, id|

Sorry, i tested the regex and it's wrong, this should fix it

%r{/(?<model>[a-z]*)(?:/(?<action>[a-z]*))?(?:/(?<id>[1-9][0-9]*))?}

On Wed, May 2, 2012 at 10:42 AM, Carlos Eduardo L. Lopes <

--
Carlos Eduardo L. Lopes
Skype: carloslopespollares | Twitter: @_carloslopes

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Eduardo L. Lopes  
View profile  
 More options May 2 2012, 9:42 am
From: "Carlos Eduardo L. Lopes" <carlos.el.lo...@gmail.com>
Date: Wed, 2 May 2012 10:42:56 -0300
Local: Wed, May 2 2012 9:42 am
Subject: Re: route :get, :delete, :post, :put, '/*/*?/?*?' do |model, action, id|

I would do this using Regexp, for me it's the better way.

something like:

route :get, :delete, :post, :put,
%r{/(?<model>.*)(?:/(?<action>.*))?(?:/(?<id>[1-9][0-9]*))?} do ...

I didn't test this code, but i think it will work

On Tue, May 1, 2012 at 3:46 AM, darthophage <darthoph...@sympatico.ca>wrote:

--
Carlos Eduardo L. Lopes
Skype: carloslopespollares | Twitter: @_carloslopes

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »