I did it this way...
class PostsController < ApplicationController
resources_controller_for :posts
def create
# do something before
super
# do something after
end
end
or like this, if you want it depending on each part...
class PostsController < ApplicationController
resources_controller_for :posts
def create
# do something before - return a boolean
super if "before boolean is true"
# do something after - if "before boolean is true" and/or
"resource_saved?"
end
end
Hope this helps :)
On 26 Feb., 21:44, Brian <
btkn...@gmail.com> wrote:
> One thing I would really like to see in resources_controller is
> something similar to what the resource_controller and make_resourceful
> plugins do. Right now with resources_controller my understanding is
> if I want to do something before or after a restful action I have do
> something like this:
>
> class PostsController < ApplicationController
> resources_controller_for :posts
> def create
> self.resource = new_resource
> resource.user = current_user
> save_resource
> end
> end
>
> The above is not very DRY across controllers and I am having to access
> internal code of the plugin.
>
> Here is how resource_controller handles it:
>
> class PostsController < ApplicationController
> resource_controller
> create.before {...@post.user = current_user}