我有回应自由职业者的项目。当项目的所有者选择像表演者这样的自由职业者时,他点击复选框响应。然后单击musst调用方法project.set_performer。我有以下代码,点击复选框后没有任何反应。
Propject.rb
# == Schema Information
#
# Table name: projects
#
# id :integer not null, primary key
# title :string
# description :text
# price :integer
# location :string
# payment :string
# anonymity :boolean
# category_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# price_category :string
# user_id :integer
# performer_id :integer
#
# Indexes
#
# index_projects_on_user_id (user_id)
#
..........................................
def set_performer(id)
response = Response.find(id)
project = response.project
project.update( performer_id: response.freelancer.id )
end
..........................................
项目/ responses.html.erb
<div class="controls">
<%= check_box_tag 'freelancer_id', @project.set_performer, false, class: 'response', data: { id: "select_freelancer_#{response.freelancer.id}" } %>
</div>