Sorry for all the questions today... Beyond the obvious things--models, controllers, helpers, and other framework-related types--where should I put the code for my own types? For example, I was thinking of writing my own AJAX-friendly paginator, but I don''t know where to put the code for that sort of thing. I would prefer to keep things object-oriented, so I would rather do a lot of work with classes (even if their lifespan is short during a request) than use helper functions for everything. Does it belong in the /vendor directory? -- 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 -~----------~----~----~----~------~----~------~--~---
Dave Smith wrote:> Sorry for all the questions today...Bring''em on.> Beyond the obvious things--models, controllers, helpers, and other > framework-related types--where should I put the code for my own types? > For example, I was thinking of writing my own AJAX-friendly paginator, > but I don''t know where to put the code for that sort of thing.The /lib folder is for stuff that doesn''t occupy the MVC triad.> I would prefer to keep things object-oriented, so I would rather do a > lot of work with classes (even if their lifespan is short during a > request) than use helper functions for everything.These should become nested classes inside their classic MVC classes. Use the lib folder for (roughly speaking) anything that could work alone, without any Rails around it.> Does it belong in the /vendor directory?Only if it''s a plugin or otherwise from someone else. -- Phlip http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jul 19, 2007, at 17:04 , Dave Smith wrote:> Beyond the obvious things--models, controllers, helpers, and other > framework-related types--where should I put the code for my own types?> Does it belong in the /vendor directory?If you''ve written them as plugins (which is a nice, portable idea). Otherwise in lib/ Michael Glaesemann grzm seespotcode net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks guys... I''m not sure how I missed the ''lib'' directory. Is everything namespaced based on its folder in there? So something in ''lib/foo/bar.rb'' will need a "require ''foo''" at the top of any file that uses it? -- 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 -~----------~----~----~----~------~----~------~--~---
On 7/19/07, Dave Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Sorry for all the questions today... > > Beyond the obvious things--models, controllers, helpers, and other > framework-related types--where should I put the code for my own types? > For example, I was thinking of writing my own AJAX-friendly paginator, > but I don''t know where to put the code for that sort of thing. >if you need an ajax friendly paginator, I''d suggest using the will_paginate plugin (http://errtheblog.com/post/4791) and then apply the following patch: http://pastie.caboo.se/80535 you can then paginate your collection of objects as follows: <%= will_paginate @products, :ajax_method => ''my_ajax_callback'' %> and of course you''d replace @products and ''my_ajax_callback'' with the name of your objects and ajax pagination method. Adam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks, I''ll try that! I''m a bit new to this... how do I "apply the patch"? -- 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 -~----------~----~----~----~------~----~------~--~---
On 7/20/07, Dave Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Thanks, I''ll try that! I''m a bit new to this... how do I "apply the > patch"?copy the contents of the patch into a new textfile, call it something like "view_helpers_ajax.patch" and place it in the same directory as your view_helpers.rb file (it''ll be in #{RAILS_ROOT}/vendor/plugins/will_paginate/lib/). Then just enter the following at the command line: patch -p0 <view_helpers_ajax.patch You should see the following output: Hmm... Looks like a unified diff to me... The text leading up to this was: -------------------------- |--- view_helpers.rb Fri Jul 20 01:55:04 2007 |+++ view_helpers_ajax.rb Fri Jul 20 01:54:26 2007 -------------------------- Patching file view_helpers.rb using Plan A... Hunk #1 succeeded at 12. Hunk #2 succeeded at 32. Hunk #3 succeeded at 46. Hunk #4 succeeded at 65. Hunk #5 succeeded at 74. Hunk #6 succeeded at 83. done if you get the above, it means that the patch was applied successfully. You''ll also find a new file in the same directory named "view_helpers.rb.orig" which is the original unpatched view_helpers.rb file (in case everything fails horribly and you want to go back to the original file). Restart your web server and you should be good to go. Adam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''m doing this in windows. I have the Gnuwin32 version of patch, but it isn''t running correctly. It crashes with a message: patching file view_helpers.rb Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354 This application has request the Runtime to terminate it.... blah blah I may just hold off. I''m sure you guys don''t want to deal with this. :-) -- 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 -~----------~----~----~----~------~----~------~--~---
Here''s my modified view_helpers.rb file. Just copy and paste it from here: http://pastie.caboo.se/80752 Adam On 7/20/07, Dave Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m doing this in windows. I have the Gnuwin32 version of patch, but it > isn''t running correctly. It crashes with a message: > > patching file view_helpers.rb > Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354 > > This application has request the Runtime to terminate it.... blah blah > > I may just hold off. I''m sure you guys don''t want to deal with this. > :-) > > -- > 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 -~----------~----~----~----~------~----~------~--~---