I am new in ruby on rails, I want to call controller method from javascript with multiple parameters. I tried but didn't got output. _applied_candidate.html.erb
<p>Next Status: <span class="fontstyle3">
<select name="workflow_id" id="workflow_id" onchange="updateItem('workflow_id', <%= applied_candidate.id %>, <%= job.id %>)">
<% data.each do | d | %>
<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 %>
<% end %>
</select>
</span>
</p>
<script type="text/javascript">
function updateItem(item, userID, jobID) {
var e = document.getElementById(item);
var val = e.options[e.selectedIndex].value;
new Ajax.Request('/jobs/update_work_flow', {
method: 'post',
parameters: { selected_id: item, u_id: userID, job_id: jobID }
});
};</script>
routes.rb
resources :jobs do
get :update_work_flow, on: :collection
end
jobs_controller.rb
def update_work_flow
redirect_to root_path
end
How to check controller method called or not
Aucun commentaire:
Enregistrer un commentaire