开发者

rails: running a method on create only

开发者 https://www.devze.com 2023-01-01 12:59 出处:网络
I want to run a paperclip method on create only has_attached_file :file This method doesn\'t seem to accept the :on => :create that so开发者_StackOverflowme other rails methods do.

I want to run a paperclip method on create only

has_attached_file :file

This method doesn't seem to accept the :on => :create that so开发者_StackOverflowme other rails methods do.

I tried:

before_create
after_create

etc, but those didn't work.

I also did:

if :create

How can I test if the controller is using the create method from the model?

Thanks!


When you use has_attached_file :file. There are 2 new callback and you can use it :

before_file_post_process
after_file_post_process

So you can use it and check if you object is in creation or not with new_record?

The before_create and after_create are allway present, but independent of your attachment.

0

精彩评论

暂无评论...
验证码 换一张
取 消