Hi, I've been working on lifecycles... I can transition between states
very nicely. I'm wanting to have one action that edits. I've got an
index page that shows the transition buttons, and I can step the model
between the states, redirecting to the index page.

app/models/my_model.rb
...
  lifecycle do
    state :saved, :default => true
    state :submitted
    state :editing
    state :deleted

    transition :delete, {:saved => :deleted}, :available_to => :owner
    transition :submit, {:saved => :submitted},  :available_to
=> :owner
    transition :save, {:editing => :saved}, :available_to => :owner
    transition :alter, {:saved => :editing}, :available_to => :owner
  end
...
app/controllers/my_model.rb
...
  def do_submit
    do_transition_action :submit do
      redirect_to my_models_path
    end
  end

  def do_alter
    do_transition_action :alter do
      redirect_to edit_my_model_path
    end
  end
...

And that's where I get lost and confused. I want to update the /
my_model/12/edit page. So I think I need to alter the <edit-page> in
app/views/my_models/edit.dryml but I need to alter just the submission
buttons in the form, don't I? I can see how to replace the entire
form, I think (<replace-content-body>...</replace-content-body>), but
I believe that what I need to do is to replace the final Submit button
in the form with my two transition buttons (I can "save" or "submit"
an object in the "editing" state). Replacing the whole form wouldn't
be DRY enough for Hobo style coding ;)

So... two issues, I suppose. How do I show transition-buttons in an
edit form, and how do I get the params into the hobo_update... I can't
see an example in the cookbook that quite covers this.

My guess at the update method for the transition is:

  def do_save
    do_transition_action :save do
      hobo_update :redirect my_models_path, :params
    end
  end

But that'll only work if I get the params, by having the buttons be
part of the form?

Thanks to your previous help, I'm having a great time with Hobo.
Making models and then sorting out permissions and then styling the
pages. Lots of fun. But this is my first brush with lifecycles.

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