我收到以下错误信息:
NoMethodError in UploadStepsController#update
undefined method `attributes= for #<ActiveRecord::Relation:0x00000104775c40>
app/controllers/upload_steps_controller.rb:12:in `update
我正在造一个巫师,允许用户上传文件, 使用邪恶巫师宝石。 我错过了什么?
< 强上加载_ steps_ controller.rb 强 >
class UploadStepsController < ApplicationController
include Wicked::Wizard
steps :audience, :rewards, :review
def show
@upload = current_user.uploads
render_wizard
end
def update
@upload = current_user.uploads
@upload.attributes = params[:upload]
render_wizard @upload
end
end
< 强 > 上载.rb 强 >
class Upload < ActiveRecord::Base
attr_accessible :title, :tagline, :category, :genre, :length, :description
belongs_to :user
validates :title, presence: true
validates :tagline, presence: true
validates :category, presence: true
validates :genre, presence: true
validates :length, presence: true
validates :description, presence: true
validates :user_id, presence: true
default_scope order: uploads.created_at DESC
end
<强 > 新错误 强>
NoMethodError in UploadStepsController#update
undefined method `save for #<ActiveRecord::Relation:0x0000010159c098>
app/controllers/upload_steps_controller.rb:13:in `update