0
我的應用程序的工作流程如下,使用angularjs前端應用程序,用戶創建一篇文章,如果成功,則必須提交圖像。用回形針更新模型
我跑rails generate paperclip article verification_token
創建以下遷移:
class AddAttachmentVerificationTokenToArticles < ActiveRecord::Migration
def self.up
change_table :articles do |t|
t.attachment :verification_token
end
end
def self.down
remove_attachment :articles, :verification_token
end
end
,並在我的控制器我創建了一個新的動作,send_verification_token
def send_verification_token
@article = current_user.articles.find(params[:id])
if @article.update_attribute(:verification_token, params[:file])
render json: @article.id, status: 201
else
render json: @article.errors, status: 422
end
end
,但我得到和錯誤,這verification_token
不是方法。回形針生成verification_token_file_name
,verification_token_content_type
,verification_token_file_size
,verification_token_updated_at
,所以我不知道我應該更新哪個屬性。
如何更新模型以上傳圖片?
我是個白癡,那失蹤 – tvieira