OK, yet another thought (can't resist).
i ran rake routes and I found the create_order_assist route:
create_order_assist POST /order_assists(.:format)
{:action=>"create", :controller=>"order_assists"}
could I do something with this, perhaps create a button that uses a
customized controller action? I'm sure I would have to define a custom
action for create inside the order_assists_controller.
I'm full of ideas but don't really know how to accomplish any of these
things. If this last suggestion I've made is the way to go, how do I
go about creating a new order_assist? Assuming I know the order and
item id's i want to give the order_assist, how do I set them in the
new model instance as/after I create it?
-a very caffeinated hoboHippy
On Oct 23, 9:23 am, hobo_hippy <[email protected]> wrote:
> ...reading through the rails api...
>
> My best guess (doing it the hard way) would be some fancy combination
> of activerecord calls to:
>
> 1) create a new order_assist
> 2) set the order_id
> 3) set the item_id
>
> is that all i'd have to do? What kind of syntax would I use inside a
> lifecycle to get this to happen? would it be like what I suggest
> below?
>
> transition :add_to_order, {:not_in_order => :in_order},
> :available_to => "User", do
> <%= rails api calls %>
> end
>
> The more I read the more questions I have, so I'll stop here and see
> what anyone might have to say!!
>
> -hoboHippy
>
> On Oct 23, 8:37 am, hobo_hippy <[email protected]> wrote:
>
>
>
>
>
>
>
> > on further thought, should I define a function in the model and call
> > that function with the lifecycle? really, the problem I'm having is I
> > have no idea on how to "manually" associate any particular item with a
> > particular order. I hope someone has run into this sort of thing
> > before and has an example!!!
>
> > -hoboHippy
>
> > On Oct 23, 8:29 am, hobo_hippy <[email protected]> wrote:
>
> > > I have three (really 4) classes working together: menus, items, orders
> > > (and order_assists). Their associations are listed below. I have
> > > lifecycles setup for items with two states, :in_order
> > > and :not_in_order. I'm already showing items on the menu show page
> > > (using auto actions for) and have edited the item cards such that the
> > > transition button shows on the card. This is all great! However, I'm
> > > shooting for having the transition associate the item to the current
> > > user's order (I can just assume the current user has an order
> > > already). I don't see any documentation in any tutorials or in the
> > > manual on how to accomplish this.
>
> > > Can it be done? Or do I want to do this another way? Create a custom
> > > form somehow? Please advise!
>
> > > menus:
> > > has_many :items, :dependent => :destroy
> > > has_many :orders
>
> > > items:
> > > belongs_to :menu
> > > has_many :order_assist
> > > has_many :orders, :through => :order_assist, :accessible => true
>
> > > orders:
> > > belongs_to :user, :creator => true
> > > belongs_to :menu
> > > has_many :order_assist
> > > has_many :items, :through => :order_assist, :accessible => true
>
> > > order_assists:
> > > belongs_to :order
> > > belongs_to :item
> > > belongs_to :menu
>
> > > -HoboHippy
--
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.