Hi, Using JRuby 1.1 and Rails 2.0, I created a small project in NetBeans that allows me to generate a dynamic dialplan in XML. In case it matters, I''m using builder-2.1.2 and activerecord-2.0.2. Going in the browser to: http://localhost:3000/routing/dialplan?Caller-Destination-Number=0 Does exactly what I want: <document type="freeswitch/xml"> <section name="dialplan" description="FreeSwitch dialplan for DoneRight"> <context name="default"> <extension name="test123"> <condition field="destination_number" expression="^.* $"> <action application="bridge" data="sofia/gateway/ doneright/404"/> </condition> </extension> </context> </section> </document> However, the arguments (Caller-Destination-Number=0) should be posted and that fails. I get a 404. % curl -F "Caller-Destination-Number=0" http://localhost:3000/routing/dialplan <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <HTML> <HEAD><TITLE>Not Found</TITLE></HEAD> <BODY> <H1>Not Found</H1> `/routing/dialplan'' not found. <HR> <ADDRESS> WEBrick/1.3.1 (Ruby/1.8.6/2008-05-30) at localhost:3000 </ADDRESS> </BODY> </HTML> My controller: def dialplan @routing = Routing.find(:first, :conditions => [''tfn like ?'', params[:''Caller-Destination-Number'']]) respond_to do |format| format.xml end end How do I avoid the 404 and will "params[:''Caller-Destination-Number'']" still work when I use a post instead of a get? I''ve searched the forums, but am none the wiser and I''ve got no clue how to approach this. Any help is appreciated. Thanks, Birgit --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > How do I avoid the 404 and will "params[:''Caller-Destination-Number'']" > still work when I use a post instead of a get? >Sounds like your routes are setup to only accept a get. params are accessed in the same way for gets & posts. Fred> I''ve searched the forums, but am none the wiser and I''ve got no clue > how to approach this. > Any help is appreciated. > > Thanks, Birgit--~--~---------~--~----~------------~-------~--~----~ 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 Fred, Thanks for your reply. Reading: http://api.rubyonrails.org/classes/ActionController/Routing.html I''ve tried several things in config/routes.rb, such as map.connect ''routing/dialplan'', :controller => ''routing'', :action => ''dialplan'', :conditions => { :method => :post } but no progress. Googling for ''post'' is like searching for a needle in a haystack. Would you mind helping out a bit more? Thanks, Birgit On 08/07/08 15:36, Frederick Cheung wrote:> >> How do I avoid the 404 and will "params[:''Caller-Destination-Number'']" >> still work when I use a post instead of a get? >> > > Sounds like your routes are setup to only accept a get. params are > accessed in the same way for gets & posts. > > Fred >> I''ve searched the forums, but am none the wiser and I''ve got no clue >> how to approach this. >> Any help is appreciated. >> >> Thanks, Birgit--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 9 Jul 2008, at 13:16, Birgit Arkesteijn wrote:> > Hi Fred, > > Thanks for your reply. > > Reading: > http://api.rubyonrails.org/classes/ActionController/Routing.html > > I''ve tried several things in config/routes.rb, such as > map.connect ''routing/dialplan'', :controller => ''routing'', > :action => ''dialplan'', > :conditions => { :method => :post } > > but no progress. > > Googling for ''post'' is like searching for a needle in a haystack. > Would you mind helping out a bit more? >What''s in your routes right now ? If you haven''t gone out of your way with conditions on your routes, resources etc... then the default controller/action/id route should still catch it whether it''s a post or a get. Fred> Thanks, Birgit > > > On 08/07/08 15:36, Frederick Cheung wrote: >> >>> How do I avoid the 404 and will "params[:''Caller-Destination- >>> Number'']" >>> still work when I use a post instead of a get? >>> >> >> Sounds like your routes are setup to only accept a get. params are >> accessed in the same way for gets & posts. >> >> Fred >>> I''ve searched the forums, but am none the wiser and I''ve got no clue >>> how to approach this. >>> Any help is appreciated. >>> >>> Thanks, Birgit > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 09/07/08 13:31, Frederick Cheung wrote:> > On 9 Jul 2008, at 13:16, Birgit Arkesteijn wrote: > >> Hi Fred, >> >> Thanks for your reply. >> >> Reading: >> http://api.rubyonrails.org/classes/ActionController/Routing.html >> >> I''ve tried several things in config/routes.rb, such as >> map.connect ''routing/dialplan'', :controller => ''routing'', >> :action => ''dialplan'', >> :conditions => { :method => :post } >> >> but no progress. >> >> Googling for ''post'' is like searching for a needle in a haystack. >> Would you mind helping out a bit more? >> > What''s in your routes right now ? If you haven''t gone out of your way > with conditions on your routes, resources etc... then the default > controller/action/id route should still catch it whether it''s a post > or a get. > > > FredHi Fred, Thanks for your reply (again). I got it working, albeit in GlassFish (not in Webrick). My routes.rb files is very basic (I removed the ''map.connect'' again): ActionController::Routing::Routes.draw do |map| map.connect '':controller/:action/:id'' map.connect '':controller/:action/:id.:format'' end When I deployed the app in question in GlassFish and I got a different error than the one in Webrick when I do a HTTP post (http get was stillOK): % curl -F "Caller-Destination-Number=0" http://apso.westhawk.co.uk:8080/Dialplan/routing/dialplan [ ... cut ... ] <title>The change you wanted was rejected (422)</title> [ ... cut ... ] <!-- This file lives in public/422.html --> <div class="dialog"> <h1>The change you wanted was rejected.</h1> <p>Maybe you tried to change something you didn''t have access to.</p> </div> I noticed in the glassfish/..../production.log: ActionController::InvalidAuthenticityToken (No :secret given to the #protect_from_forgery call. Set that or use a session store capable of generating its own keys (Cookie Session Store).): After googling, I commented out the in app/controllers/application.rb protect_from_forgery # :secret => ''xxxx'' line. It''s a bit of a pain that it doesn''t work in Webrick. It makes development harder. Thanks, Birgit --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 9 Jul 2008, at 14:17, Birgit Arkesteijn wrote:> > > > I noticed in the glassfish/..../production.log: > ActionController::InvalidAuthenticityToken (No :secret given to the > #protect_from_forgery call. Set that or use a session store capable > of > generating its own keys (Cookie Session Store).): > > After googling, I commented out the in app/controllers/application.rb > protect_from_forgery # :secret => ''xxxx''Ah yes. That only applies to post requests (but you''ll only hit that error after the correct action has been routed too)> > line. > > It''s a bit of a pain that it doesn''t work in Webrick. It makes > development harder.Were you restarting webrick after changing routes.rb ? Fred> > > Thanks, Birgit > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 09/07/08 14:29, Frederick Cheung wrote:> > On 9 Jul 2008, at 14:17, Birgit Arkesteijn wrote: > >> >> >> I noticed in the glassfish/..../production.log: >> ActionController::InvalidAuthenticityToken (No :secret given to the >> #protect_from_forgery call. Set that or use a session store capable >> of >> generating its own keys (Cookie Session Store).): >> >> After googling, I commented out the in app/controllers/application.rb >> protect_from_forgery # :secret => ''xxxx'' > > Ah yes. That only applies to post requests (but you''ll only hit that > error after the correct action has been routed too) >> line. >> >> It''s a bit of a pain that it doesn''t work in Webrick. It makes >> development harder. > > Were you restarting webrick after changing routes.rb ? > > Fred >> >> Thanks, BirgitHi Fred, When I first encountered the Webrick problem, my routes.rb was the plain default one. Just to be sure, I just added the ''map.connect'' back and restarted webrick. Same problem. In my Netbeans webrick output window, I get: #<WEBrick::HTTPStatus::BadRequest: invalid body size.> ["/home/birgit/.netbeans/6.1/jruby-1.1/lib/ruby/1.8/webrick/httprequest.rb:288:in `read_body''", This might well be a Netbeans/Webrick error, see http://jira.codehaus.org/browse/JRUBY-2446?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel I''m not running on a windows platform, but otherwise, the conditions are the same: NetBeans 6.1, JRuby 1.1, gems 1.8 Thanks, Birgit --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 9 Jul 2008, at 14:50, Birgit Arkesteijn wrote:> > Hi Fred, > > When I first encountered the Webrick problem, my routes.rb was the > plain > default one. Just to be sure, I just added the ''map.connect'' back and > restarted webrick. Same problem. > > In my Netbeans webrick output window, I get: > #<WEBrick::HTTPStatus::BadRequest: invalid body size.> > ["/home/birgit/.netbeans/6.1/jruby-1.1/lib/ruby/1.8/webrick/ > httprequest.rb:288:in > `read_body''", >> This might well be a Netbeans/Webrick error, see > http://jira.codehaus.org/browse/JRUBY-2446?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel >Ah yes that does rather look like the same thing. You shouldn''t need anything other than the default in routes.rb but if webrick is not playing ball then I suppose that''s its fault (or possibly jruby''s fault) Fred> > I''m not running on a windows platform, but otherwise, the conditions > are > the same: NetBeans 6.1, JRuby 1.1, gems 1.8 > > > Thanks, Birgit > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 09/07/08 14:59, Frederick Cheung wrote:> > On 9 Jul 2008, at 14:50, Birgit Arkesteijn wrote: >> Hi Fred, > >> This might well be a Netbeans/Webrick error, see >> http://jira.codehaus.org/browse/JRUBY-2446?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel >> > > Ah yes that does rather look like the same thing. You shouldn''t need > anything other than the default in routes.rb but if webrick is not > playing ball then I suppose that''s its fault (or possibly jruby''s fault) > > Fred >> I''m not running on a windows platform, but otherwise, the conditions >> are >> the same: NetBeans 6.1, JRuby 1.1, gems 1.8 >> >> >> Thanks, BirgitThanks, Fred, for all your help. It''s a bummer, but at least I can do some development using HTTP get and test it properly using a HTTP post by deploying it. Thanks, Birgit --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---