Re: Camping into production
On Wed, Oct 12, 2011 at 22:20, Nokan Emiro 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 "". ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Passenger, Rack and __END__ error
I might be missing something stupid.. but Passenger doesn't like __END__ http://pastie.org/2689517 Same code (omitting requires) fine in Camping server, not with Passenger/Rack: compile error config.ru:33: syntax error, unexpected $end, expecting ')' __END__ ^ Works fine under Passenger without __END__ - probably a Rack issue, but looking for clues here... Ruby 1.8.6 Rack 1.3.4 Passenger 3.0.9 Apache 2.2.17 Camping 2.1.467 DaveE BTW love @@/styles.css - saved 6 lines of code :-) ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Passenger, Rack and __END__ error
Try to split it up in two files: app.rb: The app config.ru: require 'app' run Nuts I don't think rackup-files can have __END__. // Magnus Holm On Thu, Oct 13, 2011 at 17:48, Dave Everitt wrote: > I might be missing something stupid.. but Passenger doesn't like __END__ > > http://pastie.org/2689517 > > Same code (omitting requires) fine in Camping server, not with > Passenger/Rack: > > compile error config.ru:33: syntax error, unexpected $end, expecting ')' > __END__ ^ > > Works fine under Passenger without __END__ - probably a Rack issue, but > looking for clues here... > > Ruby 1.8.6 > Rack 1.3.4 > Passenger 3.0.9 > Apache 2.2.17 > Camping 2.1.467 > > DaveE > BTW love @@/styles.css - saved 6 lines of code :-) > > ___ > Camping-list mailing list > Camping-list@rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Camping into production
> 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. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
how to catch 404s?
How can I hide/catch the "Camping problem! /xxx not found" pages? It would be great to define my own handler instead, or simply redirect to the root of my app. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
which view am I inside?
How can I guess the view's name in my layout method? It would be great to know because of highlight the current menu item the user has selected. Of course I can store it in a variable in my controller just before I call render :view, but I hope there's a much more sexy way to do this. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Passenger, Rack and __END__ error
On 13.10.2011 20:02, Magnus Holm wrote: I don't think rackup-files can have __END__. https://github.com/rack/rack/blob/master/test/builder/end.ru – Matthias ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Camping into production
On Thu, Oct 13, 2011 at 21:16, Nokan Emiro 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? ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Passenger, Rack and __END__ error
2011/10/13 Matthias Wächter : > On 13.10.2011 20:02, Magnus Holm wrote: >> >> I don't think rackup-files can have __END__. > > https://github.com/rack/rack/blob/master/test/builder/end.ru > > – Matthias It's broken: https://github.com/rack/rack/pull/253 (it only handles one line of content) ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: which view am I inside?
On Thu, Oct 13, 2011 at 21:33, Nokan Emiro wrote: > How can I guess the view's name in my layout method? > > It would be great to know because of highlight the current > menu item the user has selected. Of course I can store it in > a variable in my controller just before I call render :view, but I > hope there's a much more sexy way to do this. If you're using Markaby (that is, templates written in Ruby under MyApp::Views) and Ruby 1.9 you can use __method__: module App::Views def foo p "I'm inside: #{__method__}" end end But you can't use that in a layout or partial though (it would just return "layout" or the name of the partial)… ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Camping into production
> > 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. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: which view am I inside?
> > > > How can I guess the view's name in my layout method? > > If you're using Markaby (that is, templates written in Ruby under > MyApp::Views) and Ruby 1.9 you can use __method__: > > module App::Views > def foo >p "I'm inside: #{__method__}" > end > end > > But you can't use that in a layout or partial though (it would just > return "layout" or the name of the partial)… > My question was about the layout. Suppose that Alfa and Beta are menu items in the layout, and I want to mark the current menu item with different appearance: module App::Views def layout case . #<--- Which view am I currently rendering? :alfa or :beta? when :alfa # generate an alfa-selected menu when :beta # generate a beta-item-selected menu end div(:class => :content) { self << yield } end def alfa "Alfa" end def beta "Beta" end end ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: how to catch 404s?
Check out Error handling down the bottom of this page: http://camping.rubyforge.org/book/51_upgrading.html — Jenna On 14/10/2011, at 6:25 AM, Nokan Emiro wrote: > How can I hide/catch the "Camping problem! /xxx not found" pages? > It would be great to define my own handler instead, or simply > redirect to the root of my app. > > ___ > Camping-list mailing list > Camping-list@rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: how to catch 404s?
module MyApp def r404(path) "404: #{path}" # or you can render a template: render :four_oh_four end end There's also r500(klass,method,exception) which gets called when an exception happens, and r501(method) which gets called when a route is found, but the controller doesn't have the method. // Magnus Holm On Thu, Oct 13, 2011 at 21:25, Nokan Emiro wrote: > How can I hide/catch the "Camping problem! /xxx not found" pages? > It would be great to define my own handler instead, or simply > redirect to the root of my app. > > > ___ > Camping-list mailing list > Camping-list@rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list