Hi, As you already know I''m working on turning my Camping app into production. Unfortunatelly I find lots of problems on my way. The next one is here: My Camping app does something dirty on the ''redirect CtrllerName'' lines. The webserver serves https requests, and before I placed fastcgi_param HTTPS on; which passes these two params to the fastcgi application: "HTTPS"=>"on", "rack.url_scheme"=>"https", But my app fails on the first redirect line in my controllers: (eval):10:in `URL'': undefined method `+'' for nil:NilClass (NoMethodError) from (eval):15:in `redirect'' from /home/bsanyi/MyApp.rb:53:in `post'' from (eval):24:in `send'' from (eval):24:in `service'' from (eval):24:in `catch'' from (eval):24:in `service'' from (eval):34:in `call'' from /usr/lib/ruby/1.8/rack/session/cookie.rb:37:in `call'' from (eval):38:in `call'' from /usr/lib/ruby/1.8/rack/content_length.rb:13:in `call'' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:57:in `serve'' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:25:in `run'' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `each'' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `run'' MyApp.rb:53 is a `redirect ControllerName` line. What do I wrong? Redirects are working with different Rack handlers than FascCGI. And I''m sure it is related to the https, because before I switched HTTPS on in my webserver, redirect worked, but to http (not https) and port 443 - which was of course a wrong combination. Now Rack know about https, and my app seems to work until the first redirect. The same happens in ruby1.8 + ubuntu packages of rack and camping (and other necessary libs), and with ruby1.9.2 and the latest gems. The above error message is from 1.8. uzlee -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111011/5c98f0b9/attachment.html>
On Tue, Oct 11, 2011 at 09:02, Nokan Emiro <uzleepito at gmail.com> wrote:> Hi, > > As you already know I''m working on turning my Camping app > into production.? Unfortunatelly I find lots of problems on my way. > The next one is here: > > My Camping app does something dirty on the ''redirect CtrllerName'' > lines.? The webserver serves https requests, and before I placed > > fastcgi_param HTTPS on; > > which passes these two params to the fastcgi application: > > "HTTPS"=>"on", > "rack.url_scheme"=>"https", > > But my app fails on the first redirect line in my controllers: > > (eval):10:in `URL'': undefined method `+'' for nil:NilClass (NoMethodError) > ??????? from (eval):15:in `redirect'' > ??????? from /home/bsanyi/MyApp.rb:53:in `post'' > ??????? from (eval):24:in `send'' > ??????? from (eval):24:in `service'' > ??????? from (eval):24:in `catch'' > ??????? from (eval):24:in `service'' > ??????? from (eval):34:in `call'' > ??????? from /usr/lib/ruby/1.8/rack/session/cookie.rb:37:in `call'' > ??????? from (eval):38:in `call'' > ??????? from /usr/lib/ruby/1.8/rack/content_length.rb:13:in `call'' > ??????? from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:57:in `serve'' > ??????? from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:25:in `run'' > ??????? from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `each'' > ??????? from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `run''Could you run `pp @env` inside the controller and paste the result here? (or in a pastie.org) require ''pp'' module MyApp::Controllers class InTheControllerThatFails def post pp @env redirect BlaBla end end end
Sensiteve parts are masked with *******. http://pastie.org/2676396 u. On Tue, Oct 11, 2011 at 9:15 AM, Magnus Holm <judofyr at gmail.com> wrote:> Could you run `pp @env` inside the controller and paste the result > here? (or in a pastie.org) > > require ''pp'' > > module MyApp::Controllers > class InTheControllerThatFails > def post > pp @env > redirect BlaBla > end > end > end >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111011/436a9e19/attachment.html>
On Tue, Oct 11, 2011 at 18:00, Nokan Emiro <uzleepito at gmail.com> wrote:> Sensiteve parts are masked with *******. > > http://pastie.org/2676396 > > u.Thanks. This is a bug in Camping which has been fixed in 5423c7a0. You can install the latest development version of Camping by running: gem install camping --source http://gems.judofyr.net/ Because we recently had a release, this patch is the only difference between the development version and the latest released version of Camping. So it should be pretty safe to use that :-)
> This is a bug in Camping which has been fixed in 5423c7a0. > > You can install the latest development version of Camping by running: > > gem install camping --source http://gems.judofyr.net/ > > Because we recently had a release, this patch is the only difference > between the development version and the latest released version of > Camping. So it should be pretty safe to use that :-) >Thanks! I had to hack a bit in camping-2.1.469.gemspec, but now it works. :) u -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111011/9020b2ed/attachment.html>
On Tue, Oct 11, 2011 at 20:46, Nokan Emiro <uzleepito at gmail.com> wrote:> Thanks!?? I had to hack a bit in camping-2.1.469.gemspec, > but now it works. :) > > uDamn, I hate these issues with YAML and gemspecs :/ I uploaded a new version that hopefully will install nicely on 1.8 too. Could you try to re-install it in 1.8 to see if there''s still a problem? gem install camping --source http://gems.judofyr.net/ If there''s still a problem, could you report the error here? And thank you very much for the help :-)
It has still the same 4 problematic lines: s.date = %q{2011-10-11 00:00:00.000000000Z} ... s.add_development_dependency(%q<rake>, ["#<YAML::Syck::DefaultKey:0xb67fdb98> 0.8.7"]) ... s.add_dependency(%q<rake>, ["#<YAML::Syck::DefaultKey:0xb67fdb98> 0.8.7"]) ... s.add_dependency(%q<rake>, ["#<YAML::Syck::DefaultKey:0xb67fdb98> 0.8.7"]) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111011/92558258/attachment.html>
> Thanks! I had to hack a bit in camping-2.1.469.gemspec, > but now it works. >I''m sorry to say this but it still does not work. :( I was incautious. After the redirect it shows the right URL in the browser. That''s fine, but now I can''t access my controllers. The redirect URL is ok, but the content is always from the < R ''/'' controller. For example if I have Index < R ''/'', a List < R ''/list'' and an Add < R ''/add'' controllers, only / is accessible, www.xxx.com/list and www.xxx.com/add goes somehow to Index. And R() calls in the view makes wrong href values. If the current URL is www.xxx.com/list (which now goes to the controller Index) and I click a link generated to controller Add, it sends me to www.xxx.com/list/add . The worst of all is that everything works fine with all other handlers except Rack::Handler::FastCGI. u. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111012/e3ca6686/attachment.html>
On Wed, Oct 12, 2011 at 21:07, Nokan Emiro <uzleepito at gmail.com> wrote:> >> Thanks!?? I had to hack a bit in camping-2.1.469.gemspec, >> but now it works. > > > I''m sorry to say this but it still does not work.? :( ?? I was incautious. > > After the redirect it shows the right URL in the browser.? That''s fine, > but now I can''t access my controllers.? The redirect URL is ok, but > the content is always from the < R ''/'' controller. For example if I have > Index < R ''/'', a List < R ''/list'' and an Add < R ''/add'' controllers, > only / is accessible,? www.xxx.com/list and www.xxx.com/add > goes somehow to Index.? And R() calls in the view makes > wrong href values.? If the current URL is www.xxx.com/list (which > now goes to the controller Index) and I click a link generated to > controller Add, it sends me to www.xxx.com/list/add . > > The worst of all is that everything works fine with all other > handlers except Rack::Handler::FastCGI. > > u.It seems to me that PATH_INFO is still not properly handled, but that it''s always empty.
> > It seems to me that PATH_INFO is still not properly handled, but that > it''s always empty. >You are right, PATH_INFO is always empty. If I fill it with the $SCRIPT_NAME value, controllers can be accessed again. But links generated by R() are still wrong: a ''Add'', :href => R(Add) on a page xxx.com/list goes to xxx.com/list/add, not to xxx.com/add . -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111012/db22f053/attachment.html>
On Wed, Oct 12, 2011 at 22:20, Nokan Emiro <uzleepito at gmail.com> wrote:>> It seems to me that PATH_INFO is still not properly handled, but that >> it''s always empty. > > You are right, PATH_INFO is always empty.? If I fill it with the > $SCRIPT_NAME > value, controllers can be accessed again.? But links generated by R() are > still wrong: > > a ''Add'', :href => R(Add) > > on a page xxx.com/list goes to xxx.com/list/add, not to xxx.com/add .SCRIPT_NAME is the mount-path. PATH_INFO is the internal app-path. So if you want your application available at xxx.com/my_app/, then the request xxx.com/my_app/add will look like this: SCRIPT_NAME="/my_app" PATH_INFO="/add" If it''s available at xxx.com/, then xxx.com/add will look like this: SCRIPT_NAME="" PATH_INFO="/add" Camping uses PATH_INFO for route dispatching and SCRIPT_NAME for route generating. In this case you probably want to explicitly set SCRIPT_NAME to "".
> SCRIPT_NAME is the mount-path. > PATH_INFO is the internal app-path. > > So if you want your application available at xxx.com/my_app/, then the > request xxx.com/my_app/add will look like this: > > SCRIPT_NAME="/my_app" > PATH_INFO="/add" > > If it''s available at xxx.com/, then xxx.com/add will look like this: > > SCRIPT_NAME="" > PATH_INFO="/add" > > Camping uses PATH_INFO for route dispatching and SCRIPT_NAME for route > generating. > > In this case you probably want to explicitly set SCRIPT_NAME to "".Thanks for these infos, it made everything clear. Actually Camping is not working in this way. My app has a whole domain, so it is the second case, where xxx.com/add is my Add controller''s path. But I have to force "/" into SCRIPT_NAME to work. If SCRIPT_NAME is empty, Camping generates strange values on R(Add). Maybe this is a bug, I don''t know, but this is what I discovered. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111013/68a33523/attachment.html>
On Thu, Oct 13, 2011 at 21:16, Nokan Emiro <uzleepito at gmail.com> wrote:> >> SCRIPT_NAME is the mount-path. >> PATH_INFO is the internal app-path. >> >> So if you want your application available at xxx.com/my_app/, then the >> request xxx.com/my_app/add will look like this: >> >> ?SCRIPT_NAME="/my_app" >> ?PATH_INFO="/add" >> >> If it''s available at xxx.com/, then xxx.com/add will look like this: >> >> ?SCRIPT_NAME="" >> ?PATH_INFO="/add" >> >> Camping uses PATH_INFO for route dispatching and SCRIPT_NAME for route >> generating. >> >> In this case you probably want to explicitly set SCRIPT_NAME to "". > > Thanks for these infos, it made everything clear.? Actually Camping > is not working in this way.? My app has a whole domain, so it is > the second case, where xxx.com/add is my Add controller''s path. > But I have to force "/" into SCRIPT_NAME to work.? If SCRIPT_NAME > is empty, Camping generates strange values on R(Add).? Maybe > this is a bug, I don''t know, but this is what I discovered.So you solved your problem? Good :-) If you have some extra time, could you add this controller: class Debug < R ''/debug-for-judofyr'' def get [@env["PATH_INFO"], @env["SCRIPT_NAME"], R(Add)].inspect end end ? explicitly set SCRIPT_NAME to empty, and then report the result you get at /debug-for-judofyr?
> > class Debug < R ''/debug-for-judofyr'' > def get > [@env["PATH_INFO"], @env["SCRIPT_NAME"], R(Add)].inspect > end > end > > ? explicitly set SCRIPT_NAME to empty, and then report the result you > get at /debug-for-judofyr? >The wrong one: ["/debug-for-judofyr", "/debug-for-judofyr", "/add"] The good one: ["/debug-for-judofyr", "", "/add"] I have to apologize you, it''s not a Camping bug. It''s an nginx one. fastcgi_param SCRIPT_NAME $fastcgi_script_name; pushes the wrong value into SCRIPT_NAME. This is in an external config file so I didn''t realize it. If I define SCRIPT_NAME as "/" or "" in the main config, it overwrites the $fastcgi_script_name value, and my app works fine. (With "/" as well as with "".) u. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111013/0d8a8612/attachment.html>