I''m getting to the point now where I really need to start trapping the errors. So from my AWDWR book, I added the following directly from the book into application.rb... def rescue_action_in_public(exception) case exception when ActiveRecord::RecordNotFound, ActionController::UnknownAction render(:file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found") else render(:file => "#{RAILS_ROOT}/public/500.html", :status => "500 Error") SystemNotifier.deliver_exception_notification( self, request, exception) end end end and copied the file...app/models/system_notifier.rb changing the first line ''pathname'' to the actual path to the base of my ruby application and then finally copied the file and folder for system_notifier...into app/views/system_notifier/exception_notification which includes the line... <% require ''pp'' -%> and I am thinking that this may be my problem - I am not sure. How do I solve it? if it matters, the complete trace of the error... (where line 54 is the line immediately after the ''end'' of the ApplicationController definition). Note that this error (development on webrick) differs slightly from (production on Apache w/fcgi) but the net effect is the same. SyntaxError (./script/../config/../app/controllers/application.rb:54: syntax error): /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in `load'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in `load'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:39:in `require_or_load'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:22:in `depend_on'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in `require_dependency'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:134:in `load_file!'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:97:in `const_load!'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:80:in `const_load!'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:71:in `prepare_application'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:37:in `dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in `handle_dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in `service'' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in `dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' script/server:3 Rendering /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/templates/rescues/layout.rhtml (500 Internal Error)
On Mar 6, 2006, at 7:26 PM, Craig White wrote:> if it matters, the complete trace of the error... (where line 54 is > the > line immediately after the ''end'' of the ApplicationController > definition). Note that this error (development on webrick) differs > slightly from (production on Apache w/fcgi) but the net effect is the > same.If you get a syntax error at the end of a file, it probably means you''re missing an ''end'' keyword. Dave
On Mon, 2006-03-06 at 19:44 -0600, Dave Thomas wrote:> On Mar 6, 2006, at 7:26 PM, Craig White wrote: > > > if it matters, the complete trace of the error... (where line 54 is > > the > > line immediately after the ''end'' of the ApplicationController > > definition). Note that this error (development on webrick) differs > > slightly from (production on Apache w/fcgi) but the net effect is the > > same. > > If you get a syntax error at the end of a file, it probably means > you''re missing an ''end'' keyword.---- I have to laugh at this because I ''added'' an extra end to your code (p 464 - Third printed version Sept 2005) it doesn''t seem right to me - but a quick test and it all seems to be happy - further testing to come Thanks Craig
On Mon, 2006-03-06 at 18:26 -0700, Craig White wrote:> I''m getting to the point now where I really need to start trapping the > errors. > > So from my AWDWR book, I added the following directly from the book into > application.rb... > > def rescue_action_in_public(exception) > case exception > when ActiveRecord::RecordNotFound, ActionController::UnknownAction > render(:file => "#{RAILS_ROOT}/public/404.html", > :status => "404 Not Found") > else > render(:file => "#{RAILS_ROOT}/public/500.html", > :status => "500 Error") > SystemNotifier.deliver_exception_notification( > self, request, exception) > end > end > > and copied the file...app/models/system_notifier.rb changing the first > line ''pathname'' to the actual path to the base of my ruby application > > and then finally copied the file and folder for system_notifier...into > app/views/system_notifier/exception_notification >---- I can get started but when it comes time to trap an error, I get the following logged (this is in production/Apache-fcgi) NameError (uninitialized constant UnknownAction): /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:195:in `const_missing'' /app/controllers/application.rb:12:in `rescue_action_in_public'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:33:in `rescue_action'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:108:in `perform_action'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `process_without_session_management_support'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in `process'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in `dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:141:in `process_request'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:53:in `process!'' /usr/lib/site_ruby/1.8/fcgi.rb:600:in `each_cgi'' /usr/lib/site_ruby/1.8/fcgi.rb:597:in `each_cgi'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:52:in `process!'' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:22:in `process!'' /home/craig/ruby-db/th-db/public/dispatch.fcgi:24 I''m a little over my head here, thinking that ''UnknownAction'' was a rails built-in class Craig
It is. Use the full name like ::ActionController::UnknownAction Kent. On 3/6/06, Craig White <craigwhite@azapple.com> wrote:> I''m a little over my head here, thinking that ''UnknownAction'' was a > rails built-in class >
On Mon, 2006-03-06 at 21:49 -0500, Kent Sibilev wrote:> It is. Use the full name like ::ActionController::UnknownAction >---- then why does it error, unitialized constant? Craig
Because Ruby tries to find UnknownAction constant in ActionWebService::Container::ActionController module. -- Kent On 3/6/06, Craig White <craigwhite@azapple.com> wrote:> On Mon, 2006-03-06 at 21:49 -0500, Kent Sibilev wrote: > > It is. Use the full name like ::ActionController::UnknownAction > > > ---- > then why does it error, unitialized constant? > > Craig > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Mon, 2006-03-06 at 22:32 -0500, Kent Sibilev wrote:> Because Ruby tries to find UnknownAction constant in > ActionWebService::Container::ActionController module. > > -- > Kent > > > On 3/6/06, Craig White <craigwhite@azapple.com> wrote: > > On Mon, 2006-03-06 at 21:49 -0500, Kent Sibilev wrote: > > > It is. Use the full name like ::ActionController::UnknownAction > > > > > ---- > > then why does it error, unitialized constant? > >---- ok - is it possible to reduce it down for someone who clearly doesn''t have a big picture view here? I see http://rails.rubyonrails.org/classes/ActionWebService/Container/ActionController/ClassMethods.html but it doesn''t make sense as to how I might implement and I am just taking this from the AWDWR book and it seemed to be ready for prime time. the http://books.pragprog.com/titles/rails/errata errata page has a note about this... ***** 464 #2298: I don''t know if this is a problem with Rails 1.0, Ruby 1.8.4, or something else entirely, but I could not get the rescue_action_in_public to load properly until I changed it. Ruby kept complaining that UnknownAction was an uninitialized constant. At first I just removed it, but that was unsatisfactory. In the end I had to change the case to use exception.class.name rather than exception, and list string constants instead of the actual class literals. Doing that made it work. I''m completely baffled about why this may be, but I''m a Ruby newbie as well as a Rails newcomer.--Jim Elliott ***** but I don''t know what ''string constants'' instead of the actual class literals means to me in this context. I know something is wrong, I don''t have the skill sets to make it right. I''m looking for a big hit with a clue stick. Thanks Craig
On Mar 6, 2006, at 7:52 PM, Craig White wrote:> I have to laugh at this because I ''added'' an extra end to your code (p > 464 - Third printed version Sept 2005)Which code? The ''rescue_exception_in_public'' method? That seems alright: one end for the def, and one for the case. I hate it when I feel stupid: what am I missing? Dave
On Mon, 2006-03-06 at 21:53 -0600, Dave Thomas wrote:> On Mar 6, 2006, at 7:52 PM, Craig White wrote: > > > I have to laugh at this because I ''added'' an extra end to your code (p > > 464 - Third printed version Sept 2005) > > Which code? The ''rescue_exception_in_public'' method? That seems > alright: one end for the def, and one for the case. > > I hate it when I feel stupid: what am I missing?---- No - you''re not stupid - I am stupid. I inserted an extra ''end'' - you told me you thought I was missing an ''end'', I had one too many...that''s why I had to laugh, you thought I was one brick short of a full load, I had one too many bricks. I thought I would need 3 ''end'' lines, 1 for the ''def'', 1 for the ''case'' command and 1 for the ''when/else'' My fault - thanks If I could get the problem with ''unitialized constant UnknownAction'' problem, I would go to sleep very happy tonight. Thanks Craig
Craig White wrote: Craig, I am having the same problem trying to start up WEBrick when I put ::Action_Controller::Base.enable_upload_progress into my environment.rb file. If you figure out what this is, can you let me know? Of course, I will do the same Thanks, Wes Gamble> > If I could get the problem with ''unitialized constant UnknownAction'' > problem, I would go to sleep very happy tonight. > > Thanks > > Craig-- Posted via http://www.ruby-forum.com/.
On Tue, 2006-03-07 at 22:55 +0100, Wes Gamble wrote:> Craig White wrote: > Craig, > > I am having the same problem trying to start up WEBrick when I put > > ::Action_Controller::Base.enable_upload_progress > > into my environment.rb file. > > If you figure out what this is, can you let me know? Of course, I will > do the same > > Thanks, > Wes Gamble > > > > > If I could get the problem with ''unitialized constant UnknownAction'' > > problem, I would go to sleep very happy tonight. > >---- will do Wes - seeing as how I took this directly out of the book (AWDWR) I sort of expected it to perform or at least have a comprehensible clarification on the errata page for the book. Craig
On Mar 7, 2006, at 6:42 PM, Craig White wrote:>>> If I could get the problem with ''unitialized constant UnknownAction'' >>> problem, I would go to sleep very happy tonight. >>> > ---- > will do Wes - seeing as how I took this directly out of the book > (AWDWR) > I sort of expected it to perform or at least have a comprehensible > clarification on the errata page for the book.Strange: what happens if you start script/console and type dave[tmp/rails 19:33:53] script/console Loading development environment. >> ActionController::UnknownAction => ActionController::UnknownAction I see that constant here. Dave
On Tue, 2006-03-07 at 19:34 -0600, Dave Thomas wrote:> On Mar 7, 2006, at 6:42 PM, Craig White wrote: > > >>> If I could get the problem with ''unitialized constant UnknownAction'' > >>> problem, I would go to sleep very happy tonight. > >>> > > ---- > > will do Wes - seeing as how I took this directly out of the book > > (AWDWR) > > I sort of expected it to perform or at least have a comprehensible > > clarification on the errata page for the book. > > > Strange: what happens if you start script/console and type > > dave[tmp/rails 19:33:53] script/console > Loading development environment. > >> ActionController::UnknownAction > => ActionController::UnknownAction > > I see that constant here.---- I see the same thing ;-( this is what I did...(pasting from earlier email)> *** in application.rb *** > def rescue_action_in_public(exception) > case exception > when ActiveRecord::RecordNotFound,ActionController::UnknownAction> render(:file => "#{RAILS_ROOT}/public/404.html", > :status => "404 Not Found") > else > render(:file => "#{RAILS_ROOT}/public/500.html", > :status => "500 Error") > SystemNotifier.deliver_exception_notification( > self, request, exception) > end > end > > and copied the file...app/models/system_notifier.rb changing the first > line ''pathname'' to the actual path to the base of my ruby application > > and then finally copied the file and folder for system_notifier...into > app/views/system_notifier/exception_notification >---- I can get started but when it comes time to trap an error, I get the following logged (this is in production/Apache-fcgi) NameError (uninitialized constant UnknownAction): /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:195:in `const_missing'' /app/controllers/application.rb:12:in `rescue_action_in_public'' ...etc. I don''t have the tools to know why this is happening Craig
Dave, As I explained in another thread, when you tried to reference any constant from the ActionController scope, Ruby tries to resolve this constant in ActionWebService::Container::ActionController module scope. This module is included by AWS during bootstrap process and happens to bear the same name. I didn''t dig this problem much, but I think it''s related to the black magic of const_missing that Rails uses. Kent. On 3/7/06, Dave Thomas <dave@pragprog.com> wrote:> > On Mar 7, 2006, at 6:42 PM, Craig White wrote: > > >>> If I could get the problem with ''unitialized constant UnknownAction'' > >>> problem, I would go to sleep very happy tonight. > >>> > > ---- > > will do Wes - seeing as how I took this directly out of the book > > (AWDWR) > > I sort of expected it to perform or at least have a comprehensible > > clarification on the errata page for the book. > > > Strange: what happens if you start script/console and type > > dave[tmp/rails 19:33:53] script/console > Loading development environment. > >> ActionController::UnknownAction > => ActionController::UnknownAction > > I see that constant here. > > > Dave > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Kent --- http://www.datanoise.com
yeah - I meant to say that... ;-) It actually was the same thread. I am rather surprised that there aren''t more people wondering about it - I am clearly not the only person to run into this problem (per the errata page). Perhaps many people aren''t motivated to trap their errors. Craig PS - thanks Kent... On Tue, 2006-03-07 at 21:00 -0500, Kent Sibilev wrote:> Dave, > > As I explained in another thread, when you tried to reference any > constant from the ActionController scope, Ruby tries to resolve this > constant in ActionWebService::Container::ActionController module > scope. This module is included by AWS during bootstrap process and > happens to bear the same name. I didn''t dig this problem much, but I > think it''s related to the black magic of const_missing that Rails > uses. > > Kent. > > On 3/7/06, Dave Thomas <dave@pragprog.com> wrote: > > > > On Mar 7, 2006, at 6:42 PM, Craig White wrote: > > > > >>> If I could get the problem with ''unitialized constant UnknownAction'' > > >>> problem, I would go to sleep very happy tonight. > > >>> > > > ---- > > > will do Wes - seeing as how I took this directly out of the book > > > (AWDWR) > > > I sort of expected it to perform or at least have a comprehensible > > > clarification on the errata page for the book. > > > > > > Strange: what happens if you start script/console and type > > > > dave[tmp/rails 19:33:53] script/console > > Loading development environment. > > >> ActionController::UnknownAction > > => ActionController::UnknownAction > > > > I see that constant here. > > > > > > Dave > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Kent > --- > http://www.datanoise.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Mar 7, 2006, at 8:00 PM, Kent Sibilev wrote:> As I explained in another thread, when you tried to reference any > constant from the ActionController scope, Ruby tries to resolve this > constant in ActionWebService::Container::ActionController module > scope. This module is included by AWS during bootstrap process and > happens to bear the same name. I didn''t dig this problem much, but I > think it''s related to the black magic of const_missing that RailsInteresting, this must have changed since 0.14. Cool, so we''ll rack this one up to a Rails bug then. Thanks Dave
On Tue, 2006-03-07 at 23:20 -0600, Dave Thomas wrote:> On Mar 7, 2006, at 8:00 PM, Kent Sibilev wrote: > > > As I explained in another thread, when you tried to reference any > > constant from the ActionController scope, Ruby tries to resolve this > > constant in ActionWebService::Container::ActionController module > > scope. This module is included by AWS during bootstrap process and > > happens to bear the same name. I didn''t dig this problem much, but I > > think it''s related to the black magic of const_missing that Rails > > Interesting, this must have changed since 0.14. > > Cool, so we''ll rack this one up to a Rails bug then. >---- I would be ever so grateful if you can provide an errata way around it - when you get time. Thanks Craig