#707 ✓resolved
Owen

Extend hobo_model and hobo_model_resource generators to accept "belongs_to" and "has_many" statements

Reported by Owen | April 21st, 2010 @ 11:10 PM | in Hobo 1.0X

Here is a sample use case:

rm -rf agility_professional
hobo agility_professional
cd agility_professional
ruby script/generate hobo_model_resource client name:string description:text hm:applications
ruby script/generate hobo_model_resource application name:string description:text bt:client hm:releases
ruby script/generate hobo_model_resource release code:string name:string description:text bt:application hm:stories
ruby script/generate hobo_model_resource release_theme name:string description:text hm:releases
ruby script/generate hobo_model_resource iteration iteration_number:integer name:string description:text bt:release hm:stories
ruby script/generate hobo_model_resource story name:string description:text bt:iteration hm:requirements hm:notes hm:conversations
ruby script/generate hobo_model_resource story_role name:string description:text hm:stories
ruby script/generate hobo_model_resource story_priority name:string description:text hm:stories
ruby script/generate hobo_model_resource note name:string description:text bt:story
ruby script/generate hobo_model_resource conversation name:string description:text bt:story
ruby script/generate hobo_model_resource requirement name:string description:text bt:story hm:tasks
ruby script/generate hobo_model_resource requirement_status name:string hm:requirements
ruby script/generate hobo_model_resource task name:string description:text bt:requirement
ruby script/generate hobo_model_resource task_status name:string description:text hm:tasks
ruby script/generate hobo_model_resource developer name:string hm:tasks

Comments and changes to this ticket

  • Matt Jones

    Matt Jones April 26th, 2010 @ 02:15 AM

    Looks interesting, but is it really going to save much typing? Especially since the logical choice would be to spell out has_many and belongs_to, which means a total savings of maybe a space - and that's assuming that you don't need to add options like :dependent or :accessible.

    Some other concerns:

    • there's a distinct possibility of leaving the app in a weird state if a model is generated with a belongs_to to a model that doesn't presently exist. Not likely to happen, but possible and might confuse users.

    • the example above appears to be generating some fairly complicated :through associations (Release to Story, for instance), as well as inferring several join tables (for instance, the table that links Developer to Task). That's adding even more complexity...

  • Tom Locke

    Tom Locke April 26th, 2010 @ 04:04 PM

    • Title changed from “Extend "hobo_model_resource" to accept "belongs_to" and "has_many" statements” to “Extend hobo_model and hobo_model_resource generators to accept "belongs_to" and "has_many" statements”

    There's not much 'serious' win here, for Hobo developers that have bought in already, but it's a nice marketing addition (i.e. looks cool in a demo) and I don't think it really hurts anything, so I'm happy for it to go in.

  • Owen

    Owen April 26th, 2010 @ 10:54 PM

    There is a HUGE demo win here. A paperclip doesn't impress when you know
    how to make one. :-)

    Since this is simple I would like to see it in soon...

    -Owen

  • Tom Locke

    Tom Locke May 4th, 2010 @ 05:04 PM

    • State changed from “new” to “resolved”

    Done in 735471e

    e.g.

    ./script/generate hobo_model_resource book name:string isbn:string bt:author bt:library hm:chapters hm:comments
    
    class Book < ActiveRecord::Base
    
      hobo_model # Don't put anything above this
    
      fields do
        name :string
        isbn :string
        timestamps
      end
    
      belongs_to :author
      belongs_to :library
    
      has_many :chapters, :dependent => :destroy
      has_many :comments, :dependent => :destroy
    
      # --- Permissions --- #
    
      ...
    
    end
    
  • Owen

    Owen May 29th, 2010 @ 12:22 AM

    • Milestone changed from Beyond Hobo 1.0 to Hobo 1.0X

    Cool...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages