I asked about this a few days ago and got no replies, so I''m asking again. I have a file called string_extensions.rb. In it, I extend the String class to include some extra functionality. I put this file into the lib/ directory of my app. But the changes made to String don''t take effect. The program acts as though the files aren''t being included. I''ve stopped and restarted the server. No go. I tried including Reloadable. No go. Is there something I''m missing? Seems like it should just work. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060718/f30485dc/attachment.html
"Rabbit" <rabbitblue@gmail.com> wrote in message news:828fe8650607180246l437c4ea4j13bd491053d8794f@mail.gmail.com... I asked about this a few days ago and got no replies, so I''m asking again. I have a file called string_extensions.rb. In it, I extend the String class to include some extra functionality. I put this file into the lib/ directory of my app. But the changes made to String don''t take effect. The program acts as though the files aren''t being included. I''ve stopped and restarted the server. No go. I tried including Reloadable. No go. Is there something I''m missing? Seems like it should just work. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails I had this problem too. My solution was to require the file in environment.rb also, my file was called string.rb, I don''t know if that will make a difference
Rabbit wrote on 18.07.2006 11:46:> I asked about this a few days ago and got no replies, so I''m asking again. > > I have a file called string_extensions.rb. In it, I extend the String class > to include some extra functionality. I put this file into the lib/ > directory > of my app. > > But the changes made to String don''t take effect. The program acts as > though > the files aren''t being included. > > I''ve stopped and restarted the server. No go. I tried including Reloadable. > No go. > > Is there something I''m missing? Seems like it should just work.Have you require the lib?
Hi Markus. Not sure what you mean by require the lib. I haven''t issued an explicit "require" statement, if that''s what you''re asking. I''ll try what Alan suggested... - Rabbit --- On 7/18/06, Markus Kolb <usenet-072006@tower-net.de> wrote:> > Rabbit wrote on 18.07.2006 11:46: > > I asked about this a few days ago and got no replies, so I''m asking > again. > > > > I have a file called string_extensions.rb. In it, I extend the String > class > > to include some extra functionality. I put this file into the lib/ > > directory > > of my app. > > > > But the changes made to String don''t take effect. The program acts as > > though > > the files aren''t being included. > > > > I''ve stopped and restarted the server. No go. I tried including > Reloadable. > > No go. > > > > Is there something I''m missing? Seems like it should just work. > > Have you require the lib? > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060721/1b803866/attachment-0001.html
i just did this today actually. put this in your environment.rb: require File.join(File.dirname(__FILE__), ''../lib/string_extensions'') and it will be included. if you are still getting errors, post the String class you wrote. ed On 7/21/06, Rabbit <rabbitblue@gmail.com> wrote:> Hi Markus. Not sure what you mean by require the lib. I haven''t issued an > explicit "require" statement, if that''s what you''re asking. > > I''ll try what Alan suggested... > > - Rabbit > > --- > > On 7/18/06, Markus Kolb <usenet-072006@tower-net.de> wrote: > > Rabbit wrote on 18.07.2006 11:46: > > > I asked about this a few days ago and got no replies, so I''m asking > again. > > > > > > I have a file called string_extensions.rb. In it, I extend the String > class > > > to include some extra functionality. I put this file into the lib/ > > > directory > > > of my app. > > > > > > But the changes made to String don''t take effect. The program acts as > > > though > > > the files aren''t being included. > > > > > > I''ve stopped and restarted the server. No go. I tried including > Reloadable. > > > No go. > > > > > > Is there something I''m missing? Seems like it should just work. > > > > Have you require the lib? > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Yah, Alan''s suggestion worked. I wonder why, if Rails automatically looks inside those directories I have to explicitly include them. If anyone has any ideas or knowledge on the matter, please share. :) - Rabbit --- On 7/21/06, Rabbit <rabbitblue@gmail.com> wrote:> > Hi Markus. Not sure what you mean by require the lib. I haven''t issued an > explicit "require" statement, if that''s what you''re asking. > > I''ll try what Alan suggested... > > - Rabbit > > --- > > > On 7/18/06, Markus Kolb <usenet-072006@tower-net.de> wrote: > > > > Rabbit wrote on 18.07.2006 11:46: > > > I asked about this a few days ago and got no replies, so I''m asking > > again. > > > > > > I have a file called string_extensions.rb. In it, I extend the String > > class > > > to include some extra functionality. I put this file into the lib/ > > > directory > > > of my app. > > > > > > But the changes made to String don''t take effect. The program acts as > > > though > > > the files aren''t being included. > > > > > > I''ve stopped and restarted the server. No go. I tried including > > Reloadable. > > > No go. > > > > > > Is there something I''m missing? Seems like it should just work. > > > > Have you require the lib? > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060721/6644249a/attachment.html
Wow Ed. That''s a whole lot of work to include a file. Why not simply... require "#{RAILS_ROOT}/lib/string_extensions" What Alan suggested works fine, I just think it''s odd... why have those directories... or maybe they''re NOT included by default, but simply provided by default... as placeholders... Hmm... Either way, thanks for the response Ed. By the way, my string extension is... def each_char each_byte { |b| yield b.chr } end - Rabbit --- On 7/21/06, Rabbit <rabbitblue@gmail.com> wrote:> > Yah, Alan''s suggestion worked. I wonder why, if Rails automatically looks > inside those directories I have to explicitly include them. > > If anyone has any ideas or knowledge on the matter, please share. :) > > - Rabbit > > --- > > On 7/21/06, Rabbit <rabbitblue@gmail.com> wrote: > > > Hi Markus. Not sure what you mean by require the lib. I haven''t issued > > an explicit "require" statement, if that''s what you''re asking. > > > > I''ll try what Alan suggested... > > > > - Rabbit > > > > --- > > > > > > On 7/18/06, Markus Kolb < usenet-072006@tower-net.de> wrote: > > > > > > Rabbit wrote on 18.07.2006 11:46: > > > > I asked about this a few days ago and got no replies, so I''m asking > > > again. > > > > > > > > I have a file called string_extensions.rb. In it, I extend the > > > String class > > > > to include some extra functionality. I put this file into the lib/ > > > > directory > > > > of my app. > > > > > > > > But the changes made to String don''t take effect. The program acts > > > as > > > > though > > > > the files aren''t being included. > > > > > > > > I''ve stopped and restarted the server. No go. I tried including > > > Reloadable. > > > > No go. > > > > > > > > Is there something I''m missing? Seems like it should just work. > > > > > > Have you require the lib? > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060721/a0cc672d/attachment.html
On 7/21/06, Rabbit <rabbitblue@gmail.com> wrote:> Wow Ed. That''s a whole lot of work to include a file. Why not simply...require "string_extensions" is sufficient> require "#{RAILS_ROOT}/lib/string_extensions" > > What Alan suggested works fine, I just think it''s odd... why have those > directories... or maybe they''re NOT included by default, but simply provided > by default... as placeholders... Hmm...lib is part of the load path, meaning that if you do require "file_name" then it''ll search in the lib dir for the filename. It exists so that you can put stuff in there and just require it into your files without having to do any of that RAILS_ROOT crap. Just like any Ruby app though, the file''s contents are loaded into memory until you require it. Pat
AH! THANK YOU Pat! I see it now! And, after a bit of thought, it makes complete sense. :) - Rabbit --- On 7/21/06, Pat Maddox <pergesu@gmail.com> wrote:> > On 7/21/06, Rabbit <rabbitblue@gmail.com> wrote: > > Wow Ed. That''s a whole lot of work to include a file. Why not simply... > > require "string_extensions" is sufficient > > > require "#{RAILS_ROOT}/lib/string_extensions" > > > > What Alan suggested works fine, I just think it''s odd... why have those > > directories... or maybe they''re NOT included by default, but simply > provided > > by default... as placeholders... Hmm... > > lib is part of the load path, meaning that if you do require > "file_name" then it''ll search in the lib dir for the filename. It > exists so that you can put stuff in there and just require it into > your files without having to do any of that RAILS_ROOT crap. Just > like any Ruby app though, the file''s contents are loaded into memory > until you require it. > > Pat > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060721/f0012a4e/attachment-0001.html