mardi 23 février 2016

How to update status value in table on each button click

i want to update status value in property table as (1 or 2 or 3 or 4) on click on each button

these are my buttons in my view file.

<td><%= link_to("Waiting for Response", rms_property_approve_property_path(property, {:status => 'Waiting for Response'}), method: :patch, class: "btn btn-success", "data-no-turbolink" => true) %><td> <td><%= link_to("No Response", rms_property_approve_property_path(property, {:status => 'No Response'}), method: :patch, class: "btn btn-danger", "data-no-turbolink" => true) %><td> <td><%= link_to("Registered", rms_property_approve_property_path(property, {:status => 'Registered'}), method: :patch, class: "btn btn-success", "data-no-turbolink" => true) %><td> <td><%= link_to("Not Interested", rms_property_approve_property_path(property, {:status => 'Not Interested'}), method: :patch, class: "btn btn-danger", "data-no-turbolink" => true) %><td>

My propertiescontroller.rb

def approve @property = Property.find(params[:property_id]) if params[:status]== 'Registered' @property.update_attributes(:status => 1) redirect_to :back, flash: {notice: "Property has been Registered."} elsif params[:status]== 'Not Interested' @property.update_attributes(:status => 2) redirect_to :back, flash: {notice: "Not Interested."} elsif params[:status]== 'Waiting for Response' @property.update_attributes(:status => 3) redirect_to :back, flash: {notice: "Waiting for Response"} elsif params[:status]== 'No Response' @property.update_attributes(:status => 4) redirect_to :back, flash: {notice: "No Response."} end end

my status column on property table

class AddColumnStatusInProperties < ActiveRecord::Migration def change add_column :properties, :status, :string end end

Here i clicked on No response button, but i'm getting this error on executing this. Any solution.

Any Help is appreciatable.

enter image description here

Aucun commentaire:

Enregistrer un commentaire