wrong number of arguments (1 for 2) ,找了好久没搞定,求大神指点迷津,谢谢
报错指向:if @feedback.update(:optype=> Feedback::OPTYPE[:complain])
class FeedbacksController < ApplicationController
before_action :feedback_permission, only:[ :complain, :update, :show, :edit, ]
def index
@optype = params[:optype]
@state = params[:state]
cond_arr = []
cond_arr << [:optype,@optype] if @optype.present?
cond_arr << [:state,@state] if @state.present?
hash = Hash[*cond_arr.flatten]
if hash.blank?
@feedbacks = Feedback.recent.where(:optype=>[2,3]).page params[:page]
else
@feedbacks = @current_user.feedbacks.recent.where(hash).page params[:page]
end
end
def new
@feedback = Feedback.new
end
def create
@feedback = Feedback.new(feedback_params)
respond_to do |format|
if @feedback.save
format.html { redirect_to feedbacks_url, notice: '创建成功' }
format.json { render :show, status: :created, location: @feedback }
else
format.html { render :new }
format.json { render json: @feedback.errors, status: :unprocessable_entity }
end
end
end
def edit
end
def update
@feedback.optype = params[:optype]
if
@feedback.optype == 1
@feedback_ids = params[:feedback]
end
respond_to do |format|
if feedback.update(feedback_params)
format.html { redirect_to feedbacks_url, notice: '更新成功.' }
format.json { render :show, status: :ok, location: @feedback }
end
end
end
def show
end
def complain
if @feedback.update(:optype=> Feedback::OPTYPE[:complain])
redirect_to items_url, notice: '发布成功.'
end
end
# def destroy
# @feedback.destroy
# respond_to do |format|
# format.html{redirect_to admin_feedbacks_url, notice:"删除成功"}
# format.json{render :no_content}
# end
# end
private
# def set_feedback
# @feedback = Feedback.find(params[:id])
# end
def feedback_permission
@feedback = Feedback.where(:id => params[:id])
end
def feedback_params
params.require(:feedback).permit(:user_id, :item_id, :state, :optype, :classify, :desc, :phone, :item_name, :fd_name)
end
end