ujs - Update a model attribute with a simple link (link_to) in Rails 3 via AJAX -


as task management app user, click "completed" link on task record task's resolution completed.

i want ajax request using rails 3 way of unobtrusive javascript (ujs). have been debugging quite while now, appreciated.

here link_to call making inside view:

<%= link_to "completed", task_path(:id => task.id, :resolution => "completed"), :remote => true, :method => :put %> 

and here update method in tasks controller:

class taskscontroller < applicationcontroller   respond_to :js    def update     @task = task.find(params[:id])     @task.update_attributes(params[:task])     respond_with(@task)   end end 

watching network traffic chrome's dev tools appears put request being made proper url, including url parameter (tasks/{:id}?resolution=completed), preview showing following error message:

template missing  missing template tasks/update, application/update {:locale=>[:en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee]}.   searched in: * "c:/documents , settings/corey quillen/my documents/software engineering/projects/cleaner card/cleaner_card/app/views" 

you need make resolution attribute of task - update:

<%= link_to "completed", task_path(:id => task.id, "task[resolution]" => "completed"), :remote => true, :method => :put %> 

in rails 4 - preferred method :patch update.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -