Sean Santry
2005-Apr-12 03:34 UTC
Using 3rd party libraries with Rails and Typo (uninitialized constants)
So I''ve got a typo blog based on the current head and everything is set up and working great. However, I wanted to give RubyPants (http://chneukirchen.org/blog/static/projects/rubypants.html) a try to "educate" the quotes in my posts and convert hypens to em dashes and such. I dropped rubypants.rb in my typo installation''s lib directory (the top level one, along with html_engine.rb and friends) and, just for testing purposes, modified the _articles.rhtml partial so that instead of <%= article.body_html %> it''s <%= RubyPants.new(article.body_html).to_html %> But, when I do this, I get an Exception that RubyPants is an unitialized constant. Isn''t stuff in "lib" supposed to be automagically loaded? Help! - Sean
David Goodlad
2005-Apr-12 03:37 UTC
Re: Using 3rd party libraries with Rails and Typo (uninitialized constants)
On Apr 11, 2005 9:34 PM, Sean Santry <rails-6SqCC7WXOXpVtazZjgo0Tw@public.gmane.org> wrote:> So I''ve got a typo blog based on the current head and everything is set > up and working great. However, I wanted to give RubyPants > (http://chneukirchen.org/blog/static/projects/rubypants.html) a try to > "educate" the quotes in my posts and convert hypens to em dashes and > such. > > I dropped rubypants.rb in my typo installation''s lib directory (the top > level one, along with html_engine.rb and friends) and, just for testing > purposes, modified the _articles.rhtml partial so that instead of > > <%= article.body_html %> > > it''s > > <%= RubyPants.new(article.body_html).to_html %> > > But, when I do this, I get an Exception that RubyPants is an > unitialized constant. Isn''t stuff in "lib" supposed to be automagically > loaded? > > Help! > > - Sean > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >Hi Sean It''s automatically _available_ to be loaded/required, but is not automatically loaded. If you''ll be using this module everywhere in your app, just add a require line to your application controller file; otherwise, just add it where necessary. Dave -- Dave Goodlad dgoodlad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or dave-eHfbeeWWzZOw5LPnMra/2Q@public.gmane.org http://david.goodlad.ca/
Sean Santry
2005-Apr-12 03:51 UTC
Re: Using 3rd party libraries with Rails and Typo (uninitialized constants)
On Apr 11, 2005, at 11:37 PM, David Goodlad wrote:> It''s automatically _available_ to be loaded/required, but is not > automatically loaded. If you''ll be using this module everywhere in > your app, just add a require line to your application controller file; > otherwise, just add it where necessary.Thanks for the quick reply David (twice in one day!). I added require ''rubypants'' to my application.rb but no luck--same error. I also tried adding the require directly to the articles_controller.rb.... - Sean
Sean Santry
2005-Apr-12 04:20 UTC
Re: Using 3rd party libraries with Rails and Typo (uninitialized constants)
On Apr 11, 2005, at 11:51 PM, Sean Santry wrote:> On Apr 11, 2005, at 11:37 PM, David Goodlad wrote: > >> It''s automatically _available_ to be loaded/required, but is not >> automatically loaded. > > I also tried adding the require directly to the > articles_controller.rb....Interesting. To get this working, after I killed the lighttpd instance under which the application was running, I had to remove the fcgi socket file the application was using. Once I did that, it started working.... bizarre... - Sean
Jarkko Laine
2005-Apr-12 07:25 UTC
Re: Using 3rd party libraries with Rails and Typo (uninitialized constants)
Sean, On 12.4.2005, at 07:20, Sean Santry wrote:> > > Interesting. To get this working, after I killed the lighttpd instance > under which the application was running, I had to remove the fcgi > socket file the application was using. Once I did that, it started > working.... bizarre... >Are you working in production environment? I got bitten by this once, too, until I remembered to delete the socket files (=kill the fcgi processes). That''s not so bizarre, actually. lighttpd just starts the processes and knows which sockets to use for a given app. Other than, they live their own life and keep your Rails app running even after lighttpd is killed. Note that this should not be the case when you are running your app in development mode. You can select the mode e.g. in your lighttpd config file: fastcgi.server = ( ".fcgi" => ( "localhost" => ( "min-procs" => 5, "max-procs" => 5, "socket" => "/tmp/diary.fcgi.socket", "bin-path" => "/Users/jarkko/Sites/diary/public/dispatch.fcgi", "bin-environment" => ( "RAILS_ENV" => "development" ) ) ) ) //jarkko> - Sean > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sean Santry
2005-Apr-12 13:20 UTC
Re: Using 3rd party libraries with Rails and Typo (uninitialized constants)
On Apr 12, 2005, at 3:25 AM, Jarkko Laine wrote:> On 12.4.2005, at 07:20, Sean Santry wrote: >> >> Interesting. To get this working, after I killed the lighttpd >> instance under which the application was running, I had to remove the >> fcgi socket file the application was using. Once I did that, it >> started working.... bizarre... > > Are you working in production environment? I got bitten by this once, > too, until I remembered to delete the socket files (=kill the fcgi > processes).Yes, that definitely explains it. I was working under the assumption that killing lighttpd also killed the associated fcgi processes. I didn''t realize that the fcgi processes lived until the socket files themselves were removed. Thanks for the explanation! - Sean