Hey, For a while now, I am thinking about implementing a feature into Rails. Since it's not a simple single liner, I thought I should get feedback on it and maybe some guidelines before I continue on with coding it.
The feature I would like to implement is nil_object pattern. Here's some code for example https://gist.github.com/3655723 As you can see, the post belongs to a user and I am printing out the user display name for every post. This is a pretty common thing in every rails app I ever saw, some preload, some let it go N+1 without caring. The problem is, that if you don't have the user in the database, the view code will fail on NoMethodError for NilClass. To Avoid this here's what I want to do: https://gist.github.com/3655751 This way, if the database has no record for that user, it will load the nil_user class and the code will now break. This can come in handy not only for the belongs_to but for the has_one relation as well. So... This is the feature I want to implement, thoughts? feedback? guidelines? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/BXbYp3KnUY0J. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.