Hi. I''m learning AcriveRecord (I''m not building web apps for now, just playing with the database layer). Problem is, when I run the following code: require ''rubygems'' require ''activerecord'' puts ''hi'' It takes about 6 seconds. I''m using a slow computer. Now, it''s no fun playing when it takes so long to ''require'' all the system. Can I accelerate things a bit? I know I can use some Ruby webserver and then the files are saved in memory compiled, but then what happens if I change my source using my editor? It won''t be re-loaded by the server. Any suggestions? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Albert Schlef wrote:> Hi. > > I''m learning AcriveRecord (I''m not building web apps for now, just > playing with the database layer). > > Problem is, when I run the following code: > > require ''rubygems'' > require ''activerecord'' > puts ''hi'' > > It takes about 6 seconds. I''m using a slow computer. Now, it''s no fun > playing when it takes so long to ''require'' all the system. > > Can I accelerate things a bit? > > I know I can use some Ruby webserver and then the files are saved in > memory compiled, but then what happens if I change my source using my > editor? It won''t be re-loaded by the server. > > Any suggestions?ActiveRecord is a huge library of code. It takes a while. If you are testing a command line sort of client, I don''t think there is a way around that. Rails does support code reloading, but that is not default ruby behaviour. Something I have done in the past is use the load method. Like in an IRB prompt, I can execute a bunch of setup, then load and execute. Change some code, load that file and execute again. require ''rubygems'' require ''activerecord'' load(''my_file.rb'') MyFile.do_something! # change my_file.rb code and save load(''my_file.rb'') MyFile.do_something! You can even shorten that to one line, so you can just go back to IRB, and hit up arrow, enter. load(''my_file.rb''); MyFile.do_something! This is one way that you can keep active record loaded, and only reload your changed code. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alex Wayne wrote:> Something I have done in the past is use the load method. Like in an > IRB prompt, I can execute a bunch of setup, then load and execute. > Change some code, load that file and execute again. > [...] > You can even shorten that to one line, so you can just go back to IRB, > and hit up arrow, enter. > > load(''my_file.rb''); MyFile.do_something!Alex, thanks! This is so obvious and I didn''t think about this. You''ve made my day :-) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---