Re: Layman stuck in the awe-inspiring "Agility tutorial" following the steps of "Task re-ordering"

22 views
Skip to first unread message

kevinpfromnm

unread,
Oct 14, 2012, 11:23:38 AM10/14/12
to hobo...@googlegroups.com
Since adding the plugin have you restarted the server process?  New gems, plugins and config/ changes aren't loaded on the fly.

On Sunday, October 14, 2012 6:51:49 AM UTC-6, moreaki wrote:
G'day

Prolog: In a spare hour of my life I had decided to dive into the Ruby/Rails/Hobo world and just check out the inspiring agility tutorial. After all, I had all the requirements installed on my Mac OS X 10.6.8, and so I would just need to follow easy to grasp instructions. And boy, was I in for a surprise! Being more of a kernel developer as my background, I haven't done any sorts web application development probably since 1999 (if you could call it that back then); and it was done mostly in C, shell and Perl. After one hour joyfully following the easy instructions (without really understanding at depth what I was changing from step to step), I had pretty much a working web app which would have probably cost me days if not weeks to develop using my antiquated (or rather inadequate) technology stack. But I got stuck in the process of adding "Task re-ordering".

Problem description: Let me just dump my session here, without further ado:

$ rails plugin install git://github.com/swanandp/acts_as_list.git
Initialized empty Git repository in /Users/moreaki/Work/OpenSource/webapps/hobo/agility/vendor/plugins/acts_as_list/.git/
remote: Counting objects: 45, done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 45 (delta 13), reused 22 (delta 1)
Unpacking objects: 100% (45/45), done.
 * branch            HEAD       -> FETCH_HEAD
$ vi app/models/story.rb 
$ vi app/models/task.rb 
$ git diff
diff --git a/app/models/story.rb b/app/models/story.rb
index ee47f9c..6b6cb02 100644
--- a/app/models/story.rb
+++ b/app/models/story.rb
@@ -11,7 +11,7 @@ class Story < ActiveRecord::Base
   belongs_to :project
   belongs_to :status, :class_name => "StoryStatus"
 
-  has_many :tasks, :dependent => :destroy
+  has_many :tasks, :dependent => :destroy, :order => :position
 
   children :tasks
 
diff --git a/app/models/task.rb b/app/models/task.rb
index 90f7418..76320a6 100644
--- a/app/models/task.rb
+++ b/app/models/task.rb
@@ -12,6 +12,8 @@ class Task < ActiveRecord::Base
   has_many :task_assignments, :dependent => :destroy
   has_many :users, :through => :task_assignments, :accessible => true, :dependent => :destroy
 
+  acts_as_list :scope => :story
+
   # --- Permissions --- #
 
   def create_permitted?
$ hobo generate migration
Hobo Command Line Interface 1.3.2

---------- Up Migration ----------
add_column :tasks, :position, :integer
----------------------------------

---------- Down Migration --------
remove_column :tasks, :position
----------------------------------

What now: [g]enerate migration, generate and [m]igrate now or [c]ancel? m
  => "m"

Migration filename: [<enter>=hobo_migration_1|<custom_name>]: install_acts_as_list
  => "install_acts_as_list"
      create  db/migrate/20121014124445_install_acts_as_list.rb
        rake  db:migrate
==  InstallActsAsList: migrating ==============================================
-- add_column(:tasks, :position, :integer)
   -> 0.0018s
==  InstallActsAsList: migrated (0.0019s) =====================================
$ vi app/views/taglibs/application.dryml 
$ vi app/views/tasks/edit.dryml
$ git diff
diff --git a/app/models/story.rb b/app/models/story.rb
index ee47f9c..6b6cb02 100644
--- a/app/models/story.rb
+++ b/app/models/story.rb
@@ -11,7 +11,7 @@ class Story < ActiveRecord::Base
   belongs_to :project
   belongs_to :status, :class_name => "StoryStatus"
 
-  has_many :tasks, :dependent => :destroy
+  has_many :tasks, :dependent => :destroy, :order => :position
 
   children :tasks
 
diff --git a/app/models/task.rb b/app/models/task.rb
index 90f7418..76320a6 100644
--- a/app/models/task.rb
+++ b/app/models/task.rb
@@ -12,6 +12,8 @@ class Task < ActiveRecord::Base
   has_many :task_assignments, :dependent => :destroy
   has_many :users, :through => :task_assignments, :accessible => true, :dependent => :destroy
 
+  acts_as_list :scope => :story
+
   # --- Permissions --- #
 
   def create_permitted?
diff --git a/app/views/taglibs/application.dryml b/app/views/taglibs/application.dryml
index c7bcf07..27537ee 100644
--- a/app/views/taglibs/application.dryml
+++ b/app/views/taglibs/application.dryml
@@ -18,6 +18,12 @@
   </old-card>
 </extend>
 
+<extend tag="form" for="Task">
+  <old-form merge>
+    <field-list: fields="description, users"/>
+  </old-form>
+</extend>
+
 <extend tag="page">
   <old-page merge>
     <footer:>
diff --git a/db/schema.rb b/db/schema.rb
index fe91e1a..840fb60 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20121013223931) do
+ActiveRecord::Schema.define(:version => 20121014124445) do
 
   create_table "projects", :force => true do |t|
     t.string   "name"
@@ -51,6 +51,7 @@ ActiveRecord::Schema.define(:version => 20121013223931) do
     t.datetime "created_at"
     t.datetime "updated_at"
     t.integer  "story_id"
+    t.integer  "position"
   end
 
   add_index "tasks", ["story_id"], :name => "index_tasks_on_story_id"

And that's where things go havoc. Upon requesting the "projects" page in my browser, rails barks at me with the following wonderful error message:

Started GET "/projects" for 127.0.0.1 at Sun Oct 14 14:47:28 +0200 2012
  SQL (0.6ms)   SELECT name
 FROM sqlite_master
 WHERE type = 'table' AND NOT name = 'sqlite_sequence'


NoMethodError (undefined method `acts_as_list' for #<Class:0x107869db0>):
  app/models/task.rb:15
  app/controllers/tasks_controller.rb:5

Rendered /Users/moreaki/.gem/ruby/1.8/gems/actionpack-3.0.17/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
Rendered /Users/moreaki/.gem/ruby/1.8/gems/actionpack-3.0.17/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.4ms)
Rendered /Users/moreaki/.gem/ruby/1.8/gems/actionpack-3.0.17/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (7.7ms)

Would anyone be willing to spare some precious minutes of his life to offer me a solution (and if willing, an explanation) to my current challenge?

Cheers and best regards



moreaki

unread,
Oct 14, 2012, 3:13:11 PM10/14/12
to hobo...@googlegroups.com
On Sunday, October 14, 2012 5:23:38 PM UTC+2, kevinpfromnm wrote:
Since adding the plugin have you restarted the server process?  New gems, plugins and config/ changes aren't loaded on the fly.
 
Thanks, that did the trick. I reckon if I had known more about the rails interna, I might have figured that one out by myself.

Bob Sleys

unread,
Oct 15, 2012, 10:40:11 AM10/15/12
to hobo...@googlegroups.com
Welcome to the world of rails and Hobo.  Don't worry about asking whatever problem you run across,  I've asked just about every dumb question there is and they haven't banned me yet.  Everyone here is beyond patient and helpful, some of the best group of people you can run across on the net.

Bob
Reply all
Reply to author
Forward
0 new messages