Given that mailers now have their own directory by default in app/mailers, should the same thinking be applied for putting observers in app/observers or app/models/observers? —P -- Paul Campbell paul@hypertiny.ie - - - - - - - - - - - - - - - - - - - web http://hypertiny.ie blog http://www.pabcas.com twitter http://www.twitter.com/paulca github http://www.github.com/paulca phone +353 87 914 8162 - - - - - - - - - - - - - - - - - - - -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Fri, Jul 16, 2010 at 13:34, Paul Campbell <paul@rslw.com> wrote:> Given that mailers now have their own directory by default in > app/mailers, should the same thinking be applied for putting observers > in app/observers or app/models/observers?"app/models/observers" would be fine by me, but I don''t think observers are ever that many that they warrant having their own directory. they''re mostly here to cleanup our models or to extract concerns tied to lifecycles of certain models which they themselves shouldn''t be concerned with. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Fri, Jul 16, 2010 at 5:01 PM, Mislav Marohnić <mislav.marohnic@gmail.com> wrote:> On Fri, Jul 16, 2010 at 13:34, Paul Campbell <paul@rslw.com> wrote: >> >> Given that mailers now have their own directory by default in >> app/mailers, should the same thinking be applied for putting observers >> in app/observers or app/models/observers? > > "app/models/observers" would be fine by me, but I don''t think observers are > ever that many that they warrant having their own directory. they''re mostlyHmmm, perhaps, although I only ever have one or two mailers in my apps...> here to cleanup our models or to extract concerns tied to lifecycles of > certain models which they themselves shouldn''t be concerned with. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. >-- Paul Campbell paul@hypertiny.ie - - - - - - - - - - - - - - - - - - - web http://hypertiny.ie blog http://www.pabcas.com twitter http://www.twitter.com/paulca github http://www.github.com/paulca phone +353 87 914 8162 - - - - - - - - - - - - - - - - - - - -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Fri, Jul 16, 2010 at 6:20 PM, Paul Campbell <paul@rslw.com> wrote:> On Fri, Jul 16, 2010 at 5:01 PM, Mislav Marohnić > <mislav.marohnic@gmail.com> wrote: >> On Fri, Jul 16, 2010 at 13:34, Paul Campbell <paul@rslw.com> wrote: >>> >>> Given that mailers now have their own directory by default in >>> app/mailers, should the same thinking be applied for putting observers >>> in app/observers or app/models/observers? >> >> "app/models/observers" would be fine by me, but I don''t think observers are >> ever that many that they warrant having their own directory. they''re mostly > > Hmmm, perhaps, although I only ever have one or two mailers in my apps...Buy it could be said that observers belong to the model layer. For me app/models is where the model layer lives generally speaking, non-persistent models and all. So they are OK there in my view and do not quite see this in the generated app layout. Of course if you prefer to put them in their own directory it is easy to add app/observers to autoload_paths in config/application.rb. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
> Buy it could be said that observers belong to the model layer. For me > app/models is where the model layer lives generally speaking, > non-persistent models and all. So they are OK there in my view and do > not quite see this in the generated app layout.I agree that they belong in the model layer, but they''re not models, hence the app/models/observers suggestion.> Of course if you prefer to put them in their own directory it is easy > to add app/observers to autoload_paths in config/application.rb.I agree that it''s easy, but my main point is raising the issue as to whether they should have their own folder by default and it seems to me that it''s a similar situation. What stands out for me it the pattern that''s now forming: app/controllers -> *_controller.rb app/views -> *.html.erb app/helpers -> *_helper.rb Mixing modelname.rb and modelname_observer.rb in the same directory to me seems both cluttered and inconsistent with how the other directories are organised. —P> > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > >-- Paul Campbell paul@hypertiny.ie - - - - - - - - - - - - - - - - - - - web http://hypertiny.ie blog http://www.pabcas.com twitter http://www.twitter.com/paulca github http://www.github.com/paulca phone +353 87 914 8162 - - - - - - - - - - - - - - - - - - - -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For what it''s worth, I''ve had this block in my 2.3.x environment.rb''s for a while and have been happy with the organizational system it yields. %w( sweepers observers mailers ).each do |path| config.load_paths.unshift File.join(Rails.root, ''app'', path) end config.action_mailer.template_root = File.join Rails.root, ''app'', ''mailer_views'' observer_files = Dir[File.join(Rails.root, ''app'', ''observers'', ''*.rb'')] config.active_record.observers = observer_files.map {|f| File.basename f, ''.rb''} Mailers, sweepers, mailer views, and observers are conceptually distinct from models, http-facing views, and controllers. Observers aren''t models/observers any more than helpers are views/helpers. –Jacob On Fri, Jul 16, 2010 at 10:15 AM, Paul Campbell <paul@rslw.com> wrote:>> Buy it could be said that observers belong to the model layer. For me >> app/models is where the model layer lives generally speaking, >> non-persistent models and all. So they are OK there in my view and do >> not quite see this in the generated app layout. > > I agree that they belong in the model layer, but they''re not models, > hence the app/models/observers suggestion. > >> Of course if you prefer to put them in their own directory it is easy >> to add app/observers to autoload_paths in config/application.rb. > > I agree that it''s easy, but my main point is raising the issue as to > whether they should have their own folder by default and it seems to > me that it''s a similar situation. > > What stands out for me it the pattern that''s now forming: > > app/controllers -> *_controller.rb > app/views -> *.html.erb > app/helpers -> *_helper.rb > > Mixing modelname.rb and modelname_observer.rb in the same directory to > me seems both cluttered and inconsistent with how the other > directories are organised. > > —P > > >> >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. >> >> > > > > -- > > Paul Campbell > paul@hypertiny.ie > - - - - - - - - - - - - - - - - - - - > web http://hypertiny.ie > blog http://www.pabcas.com > twitter http://www.twitter.com/paulca > github http://www.github.com/paulca > phone +353 87 914 8162 > - - - - - - - - - - - - - - - - - - - > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Fri, Jul 16, 2010 at 9:33 PM, Jacob Rothstein <rails@jacobrothstein.com> wrote:> For what it''s worth, I''ve had this block in my 2.3.x environment.rb''s > for a while and have been happy with the organizational system it > yields. > > %w( sweepers observers mailers ).each do |path| > config.load_paths.unshift File.join(Rails.root, ''app'', path) > endFor the archives, this is now autoload_paths. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Just to chime in: I always place my observers in their own folder (usually app/ observers), so I''d +1 a specific folder for them. On Jul 16, 1:15 pm, Paul Campbell <p...@rslw.com> wrote:> > Buy it could be said that observers belong to the model layer. For me > > app/models is where the model layer lives generally speaking, > > non-persistent models and all. So they are OK there in my view and do > > not quite see this in the generated app layout. > > I agree that they belong in the model layer, but they''re not models, > hence the app/models/observers suggestion. > > > Of course if you prefer to put them in their own directory it is easy > > to add app/observers to autoload_paths in config/application.rb. > > I agree that it''s easy, but my main point is raising the issue as to > whether they should have their own folder by default and it seems to > me that it''s a similar situation. > > What stands out for me it the pattern that''s now forming: > > app/controllers -> *_controller.rb > app/views -> *.html.erb > app/helpers -> *_helper.rb > > Mixing modelname.rb and modelname_observer.rb in the same directory to > me seems both cluttered and inconsistent with how the other > directories are organised. > > —P > > > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > > To post to this group, send email to rubyonrails-core@googlegroups.com. > > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-core?hl=en. > > -- > > Paul Campbell > p...@hypertiny.ie > - - - - - - - - - - - - - - - - - - - > webhttp://hypertiny.ie > bloghttp://www.pabcas.com > twitterhttp://www.twitter.com/paulca > githubhttp://www.github.com/paulca > phone +353 87 914 8162 > - - - - - - - - - - - - - - - - - - --- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
matthewrudyjacobs@gmail.com
2010-Jul-18 00:17 UTC
Re: Giving observers their own directory
I chose app/models/observers for mine But soon enough I got rid of them all Rafactoring their functionality away. I feel like observers sound like a good idea But generally end up better implemented in a different way. So giving them their own folder.. I don''t mind. On Jul 16, 6:07 pm, Trek <trek.glowa...@gmail.com> wrote:> Just to chime in: > I always place my observers in their own folder (usually app/ > observers), so I''d +1 a specific folder for them. > > On Jul 16, 1:15 pm, Paul Campbell <p...@rslw.com> wrote: > > > > > > Buy it could be said that observers belong to the model layer. For me > > > app/models is where the model layer lives generally speaking, > > > non-persistent models and all. So they are OK there in my view and do > > > not quite see this in the generated app layout. > > > I agree that they belong in the model layer, but they''re not models, > > hence the app/models/observers suggestion. > > > > Of course if you prefer to put them in their own directory it is easy > > > to add app/observers to autoload_paths in config/application.rb. > > > I agree that it''s easy, but my main point is raising the issue as to > > whether they should have their own folder by default and it seems to > > me that it''s a similar situation. > > > What stands out for me it the pattern that''s now forming: > > > app/controllers -> *_controller.rb > > app/views -> *.html.erb > > app/helpers -> *_helper.rb > > > Mixing modelname.rb and modelname_observer.rb in the same directory to > > me seems both cluttered and inconsistent with how the other > > directories are organised. > > > —P > > > > -- > > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > > > To post to this group, send email to rubyonrails-core@googlegroups.com. > > > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-core?hl=en. > > > -- > > > Paul Campbell > > p...@hypertiny.ie > > - - - - - - - - - - - - - - - - - - - > > webhttp://hypertiny.ie > > bloghttp://www.pabcas.com > > twitterhttp://www.twitter.com/paulca > > githubhttp://www.github.com/paulca > > phone+353 87 914 8162 > > - - - - - - - - - - - - - - - - - - --- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.