On Lunes, 8 de Marzo de 2010 16:01:37 helmerj escribió:
> Hi I am developing an ordering system. Once an oder is complete it can
> be searched in an active scaffold view. I would like to implement the
> following but cant get it to work:
>
> 1. have a custom action link on a per record basis (:type => :record)
> 2. Have the link direct to the new_order_path (:controller
> => :orders, :action => :create maybe?)
:action => :new
> 3. initialize the new order form (active scaffold as well), with the
> parameters of the record the reorder custom action link was clicked.
Override do_new and fill the fields in @record, or load the record and clone it
(@record = Order.find(params[:id]).clone)
>
> I would like to override 3 fields (user_id, date, and quantity):
>
> * date should always be Time.now (is set in helper) I don't know if
> that would override any other procedure...
> * user_id should always default to @current_user.id
> * quantity should just be empty as th user is suppose to always
> specify the required quantity.
You can fill that fields in do_new, or if you don't want to show the fields in
the form but save those values, you can set them in before_create_save:
def before_create_save(record)
record.date = Time.now
record.user = @current_user
end
>
> Anybody have a pointer? I tried to use the :parameters => option for
> custom links don't seem to be able to figure this out...
>
> Any help would be greatly appreciated.
--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.