1 How to patch form.
You can use a hook from the core. Here is hook list
Or if you need to patch a view where no hooks you can use gem deface
. Please see this commit
2 How to patch controller.
It is a problem, because you can't use before_filter
or alias_method_chain
in this case - Project is initialized inside method.
I suppose that you would like to do some action after (or before) project is created and you need to know selected_tasks
. My idea is to follow standart workflow and pass these values to model through new virtual attr_writer
.
What I think you should do:
- add
attr_writer
to model project - define new
safe_attribute
smth like this (I think Redmine won't allow assign unsafed attributes, see this) - add
before_create
orafter_create
callback to process accepted params throughattr_writer
.
PS of course it is just a plan and I can't check if it works :)
Plan B
There is a new (simpler) idea how to patch. Code for patching can be placed to after_filter
where you can check if @project
has been created successfully and process selected_tasks
.
You can patch core from pluging adding after_filter
this way. Do not forget to include your patch to controller see this