开发者

rails: running a method on create only

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜