Agility tutorial - can't get accessible associations to work - no javascript control

31 views
Skip to first unread message

kiwi lloyd

unread,
Jan 4, 2013, 8:49:45 AM1/4/13
to hobo...@googlegroups.com
Hi
I am having real problems getting the Accessible Associations to work in the Hobo Agility Tutorial.  I have walked through the tutorial and have got stuck on the "Associations" section - the javascript control to associate "users" to "tasks" doesn't appear.  I am logged in as admin.

Any help would be really appreciated as I don't know how to track down the problem. Thanks very much.

Below are the main gems and model files. Screen shot is attached.
  • gem 'rails', '3.2.10'
  • gem "hobo", "= 2.0.0.pre7"
  • gem "will_paginate", :git => "git://github.com/Hobo/will_paginate.git"
  • gem "hobo_jquery_ui", "2.0.0.pre7"
  • gem "hobo_clean", "2.0.0.pre7"
  • gem "jquery-ui-themes", "~> 0.0.4"
  • gem "hobo_clean_admin", "2.0.0.pre7"
tasks.rb
class Task < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    description :string
    timestamps
  end
  belongs_to :story, :inverse_of => :tasks
  has_many :task_assignments, :dependent => :destroy, :inverse_of => :task
  has_many :users, :through => :task_assignments, :accessible => true, :dependent => :destroy
  
  attr_accessible :description
...

users.rb
class User < ActiveRecord::Base

  hobo_user_model # Don't put anything above this

  fields do
    name          :string, :required, :unique
    email_address :email_address, :login => true
    administrator :boolean, :default => false
    timestamps
  end
  validates_presence_of :name
  has_many :task_assignments, :dependent => :destroy, :inverse_of => :user
  has_many :tasks, :through => :task_assignments, :accessible => true, :dependent => :destroy
  
  attr_accessible :name, :email_address, :password, :password_confirmation
...
task_assignments.rb
class TaskAssignment < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    timestamps
  end
  belongs_to :user, :inverse_of => :task_assignments
  belongs_to :task, :inverse_of => :task_assignments
  
  attr_accessible 
...
Agility-Edit Task.jpg

Bryan Larsen

unread,
Jan 5, 2013, 12:38:43 AM1/5/13
to hobo...@googlegroups.com
The agility tutorial has not been updated for Hobo 2.0 or current
Rails yet. I'm slowly working my way through the documentation and
am about half done. Unfortunately the tutorial is in the half that
isn't done.

You need to add your associations to your attr_accessible for them to
be visible on the forms. You probably don't need all of what I'm
adding below, but you will need some:
attr_accessible :description, :story, :story_id, task_assignments, :users

> ...
>
> users.rb
> class User < ActiveRecord::Base
>
> hobo_user_model # Don't put anything above this
>
> fields do
> name :string, :required, :unique
> email_address :email_address, :login => true
> administrator :boolean, :default => false
> timestamps
> end
> validates_presence_of :name
> has_many :task_assignments, :dependent => :destroy, :inverse_of => :user
> has_many :tasks, :through => :task_assignments, :accessible => true,
> :dependent => :destroy
>
> attr_accessible :name, :email_address, :password, :password_confirmation

attr_accessible :name, :email_address, :password,
:password_confirmation, :task_assignments, :tasks


> ...
> task_assignments.rb
> class TaskAssignment < ActiveRecord::Base
>
> hobo_model # Don't put anything above this
>
> fields do
> timestamps
> end
> belongs_to :user, :inverse_of => :task_assignments
> belongs_to :task, :inverse_of => :task_assignments
>
> attr_accessible

attr_accessible :task, :task_id, :user, :user_id


Bryan

kiwi lloyd

unread,
Jan 6, 2013, 3:50:08 PM1/6/13
to hobo...@googlegroups.com
This worked a treat - all fixed.  Thank you so much Bryan!

cheers
Lloyd
Reply all
Reply to author
Forward
0 new messages