I need/want to create actions using a number. For example: class ClickController < ApplicationController caches_page(:index, :100, :200) def index end def 100 end def 200 end end I keep running into problems with the numbers. Unexpected integer, etc. Single-quoting them in the cashes_page command got rid of the errors on that line, but how do I define an action with a number as its name? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
hi,> def 100 > end > > errors on that line, but how do I define an action with a number as > its name? >I''d say you cannot. A method name should start with a non-numeric character. Anyway you could define a route for each of the actions in your routes.rb being verbose, you could define the actions in the controller as action_100, for example, and just make the route to ''Clicks/100'' go to :action=>''action_100'' but if you are going to have a bunch of actions like those, i think this would do better map.connect '':controller/:action_number/'',:conditions=>{:action_number=>/\d/}, :action=>''numeric_dispatch'' that way, if in any of your controllers you receive an action with only digits, it will call "numeric_dispatch" on that controller passing the :action_number param. just be sure you define it before the default routes, so it gets higher priority regards, javier ramÃrez --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
hi again i realized i had a small mistake.. just use the following map.connect map.connect '':controller/:action_number/'',:requirements=>{:action_number=>/\d+/}, :action=>''numeric_dispatch'' cheers, javier ramirez --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Turns out by prefixing the def name with an underscore works: def _100 end Cheers. On Aug 7, 6:42 pm, partydrone <partydr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I need/want to create actions using a number. For example: > > class ClickController < ApplicationController > > caches_page(:index, :100, :200) > > def index > end > > def 100 > end > > def 200 > end > end > > I keep running into problems with the numbers. Unexpected integer, > etc. Single-quoting them in the cashes_page command got rid of the > errors on that line, but how do I define an action with a number as > its name? > > Thanks.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---