我是 ROR 的新手,我试图将用户的字段从 null 更新为 1。我已经为此编写了 c 控制器
def update_users
Rails.logger.info("in Update users")
@user = User.find(params[:id])
@user.deleted=1
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to @user, notice: 'User was successfully Deleted.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
并在路线中将其定义为-
match '/update_users' => 'users#update_users', :as => 'update_users', :via => [:put]
我对此的看法是——
= link_to raw('<span class="delete">Delete User</span>'), update_users_path(@user.id),
:method => :put,
:data => { :confirm => 'Are you sure?' },
:remote =>true
但在输出 i 中,得到 /update_users.7 而不是 /update_users/7。在网络方面我得到-
ActiveRecord::RecordNotFound in UsersController#update_users
Couldn't find User without an ID
请帮忙