IMHO I don't see the great advantage of polymorphic associations for
something like comments.  I prefer the approach that Tiago used in his
Tutorial 20 in Rapid Rails with Hobo.  It just seems cleaner and simpler.

If I had 100 tables that I was logging with some common class, then I would
use polymorphic.

Perhaps my database background is clouding my vision, and someone else can
shed some light on when and when not to polymorph.

-Owen

On Fri, Apr 2, 2010 at 7:03 AM, atmorell <[email protected]> wrote:

> Hello,
>
> I thought it would be a good idea to change my comments to be
> polymorpic - reduce tables. However hobo dumps an error on me when I
> try to create the inline comment form (see blow)  If I change the
> CommentsController to auto_actions :all, comments will be displayed at
> the bottom at the page, but the new_comment link is missing. :/ Why?
> (:accesible => true)
>
> Painting model:
>  has_many :comments, :as => :commentable, :accessible => true
>
> Comment model:
>  belongs_to :user, :creator => true
>  belongs_to :commentable, :polymorphic => true
>  never_show :commentable
>
> class CommentsController < ApplicationController
>  hobo_model_controller
>  auto_actions :destroy
>  auto_actions_for :painting, [:create]
> end
>
> class PaintingHints < Hobo::ViewHints
>  children :comments
> end
>
> Fri Apr 02 12:50:02 +0200 2010: Read error: #<NoMethodError: undefined
> method `macro' for nil:NilClass>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/whiny_nil.rb:52:in `method_missing'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/
> model_controller.rb:261:in `auto_actions_for'
> /Users/atmorell/Sites/blog/app/controllers/comments_controller.rb:5
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:380:in
> `load_without_new_constant_marking'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:380:in `load_file'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:521:in `new_constants_in'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:379:in `load_file'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:259:in `require_or_load'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:425:in `load_missing_constant'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:80:in `const_missing'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:92:in `const_missing_before_generators'
> /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails_generator/
> lookup.rb:15:in `const_missing'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/inflector.rb:361:in `constantize'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/inflector.rb:360:in `each'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/inflector.rb:360:in `constantize'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/core_ext/string/inflections.rb:162:in `constantize'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/
> model_controller.rb:61:in `all_controllers'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/
> model_controller.rb:57:in `each'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/
> model_controller.rb:57:in `all_controllers'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:
> 97:in `add_routes_for'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:
> 83:in `add_routes'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:
> 83:in `each'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:
> 83:in `add_routes'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/rails/../lib/hobo.rb:
> 73:in `add_routes'
> /Users/atmorell/Sites/blog/config/routes.rb:6
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/
> action_controller/routing/route_set.rb:226:in `draw'
> /Users/atmorell/Sites/blog/config/routes.rb:1
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:145:in
> `load_without_new_constant_marking'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:145:in `load'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:521:in `new_constants_in'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/
> active_support/dependencies.rb:145:in `load'
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/
> action_controller/routing/route_set.rb:286:in `load_routes!'
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/
> action_controller/routing/route_set.rb:286:in `each'
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/
> action_controller/routing/route_set.rb:286:in `load_routes!'
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/
> action_controller/routing/route_set.rb:266:in `load!'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:
> 10:in `reload_without_hobo_assemble'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:
> 22:in `reload'
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/
> action_controller/dispatcher.rb:58:in
> `reload_application_without_dryml_generators'
> /Users/atmorell/.gem/ruby/1.8/gems/hobo-1.0.0/lib/hobo/dryml/
> dryml_generator.rb:32:in `reload_application'
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/
> action_controller/reloader.rb:33:in `run'
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/
> action_controller/dispatcher.rb:108:in `call'
> /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:
> 31:in `call'
> /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in
> `call'
> /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in
> `each'
> /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in
> `call'
> /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/
> log_tailer.rb:17:in `call'
> /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/
> content_length.rb:13:in `call'
> /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in
> `call'
> /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/
> mongrel.rb:64:in `process'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
> `process_client'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
> `each'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
> `process_client'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
> `initialize'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
> `new'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
> `initialize'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
> `new'
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/
> mongrel.rb:34:in `run'
> /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:
> 111
> /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `gem_original_require'
> /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `require'
> script/server:3
>
>
> Best regards.
> Asbjørn Morell
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<hobousers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.
>
>


-- 
Thanks,
- Owen

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to