mercredi 12 octobre 2016

How to update data base table when select an item from drop down menu in rails

I am new in ruby on rails, I have a drop down menu bar, I want to select an item from drop down menu bar at that time, database table should to update according to the selected item. _applied_candidate.html.erb this is my partial page

 <p>Current Status: <span class="fontstyle3">
          <% data = CandidateWorkFlow.select(:workflow_step, :next_step).where("step_id = ?", offer_state.current_step) %>            
          <% data.each do | d | %>
            <%= d.workflow_step %>
          <% end %>                    
        </span></p>

        <p>Next Status: <span class="fontstyle3">             
            <% data.each do | d | %>
              <select name="user[role_id]" id="workflow_id">
                <option value="">Please select</option>
                <% d.next_step.split(',').each do | s | %>
                  <% data1 = CandidateWorkFlow.select(:workflow_step).where("step_id = ?",s) %>                   
                   <% data1.each do |l| %>
                      <option value=<% s %> > <%= l.workflow_step %> </option>          
                    <% end %>
                  <% end %>
                </select>
            <% end %>  
        </span>
        </p>

> <%= l.workflow_step %> in this <%s%> the value of items and <%=l.workflow_step%> is list, when select <%=l.workflow_step%> list then update method should be call. AppliedAJob.rbthis is my model

class AppliedJob < ActiveRecord::Base 
end

applied_jobs this is my database table | id | user_id | job_posting_id | status | applied_by_id | current_step | prev_step | these are my field JobsController.rb this is my controller

class Candidate::JobsController < Candidate::BaseController
end

But in this there is no update method

Can be update database value with the help of model method please help me

Aucun commentaire:

Enregistrer un commentaire