I'm trying to implement a lifecycle in Hobo but I am completely
stumped as to how to start it.

I have a number of sites which have one or more surveys:

class Site < ActiveRecord::Base

  fields do
    code        :string, :required, :unique, :name => true
    timestamps
  end

  has_many :surveys, :dependent => :destroy
end

Each survey goes through a lifecycle of register, submit, accept/
reject.

class Survey < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    date              :datetime, :name => true
    timestamps
  end

  belongs_to :site

  lifecycle do
    state :planned, :submitted, :accepted, :rejected

    create :register, :params => [:date, :site], :become => :planned,
      :available_to => "User",
      :user_becomes => :observer  do
      end

    transition :submit, {:planned => :submitted},
      :params => [:date],
      :available_to => [:observer, "acting_user.administrator?"]  do
      end

    transition :accept, {[:submitted, :rejected] => :accepted},
      :available_to => "acting_user.administrator?",
      :user_becomes => :checked_by do
      end

    transition :cancel, {:planned => :destroy},
      :available_to => [:observer, "acting_user.administrator?"]  do
      end
  end
end

The controller for survey is:

class SurveysController < ApplicationController

  hobo_model_controller

  auto_actions :all, :except => [:index, :create, :new]

  auto_actions_for :site, [:new, :create]

end


However, this creates a link to the new page for Survey on the show
page for site.  How do I create a link to the register page for the
Survey lifecycle?

-- 
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