Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:54:35+00:00 2026-06-12T16:54:35+00:00

I have the following code: tasks/_form.html.haml %h3 Tasks %span.form-inline.centered = form_for [@activity, @task], remote:

  • 0

I have the following code:

tasks/_form.html.haml

%h3 
    Tasks
%span.form-inline.centered
    = form_for [@activity, @task], remote: true do |f|
        = f.text_field :description, {placeholder: 'Enter task description and click + to create a new task', class: 'input-task'}
        = f.submit "+", class: 'btn btn-danger'

controllers/tasks_controller.rb

  def create
    activity = Activity.find(params[:activity_id])

    flash[:error] = I18n.t "errors.task.generic" if !activity.add_task!(params[:task])    

    @task = activity.tasks.last

    respond_to do |format|
      format.html { redirect_to activity_path(activity) }
      format.js
    end
  end

tasks/create.js.erb

$('#incomplete-tasks').append("<%= j render partial: 'task', locals: {task: @task} %>");

tasks/_task.html.haml

%li
    = task.description
    = link_to "Done", activity_task_path(task.activity, task: task), html_options = {method: :put, class: 'pull-right'}

The problem that I have is when it tries to use js to render the partial my restful resource activity_task_path sends a get method instead of the put method that I am specifying. If I don’t use js to render it and i just refresh the browser it works fine. I now get a routing error because I do no have a show page. I don’t however need one. I just need it to update my task via a put method. If anybody can shed some light on why this is happening I would appreciate it.

[EDIT1]

If you have any questions or need me to add any code or anything else that I can do to help let me know. I really don’t understand why this is happening. Thank you.

[EDIT2]

  def update
    activity = Activity.find(params[:id])
    activity.update_task!(params[:task])
    redirect_to activity_path(params[:id])
  end

This is my update controller.

[EDIT3]

You can find the app online at https://trackit.mlpinit.com to get a better understanding of what I am trying to do.
You can authenticate with a random email address I have confirmation set to 2.days.

[EDIT4]

Hopping to make it more clear… Here is the error I get when I add a new task through ajax.

Routing Error

No route matches

 {:action=>"show", :controller=>"tasks", :task=>#<Task id: 64, description: "lalala", complete: false, created_at: "2012-10-11 19:41:22", updated_at: "2012-10-11 19:41:22", activity_id: 6>, :activity_id=>#<Activity id: 6, title: "Lala", description: "this is lala", created_at: "2012-10-10 18:37:18", updated_at: "2012-10-10 18:37:18", user_id: 2, activity_group_id: nil>}

Once again if I don’t do this through an ajax call it works ok. My assumption is that the problem takes place because it doesn’t understand the put method for some reason…

[EDIT5]

If I take of the link from my _task partial the append happens without any errors. I thought I should mention that

[EDIT6]

I will add a visual walkthrough to make sure that I make myself understood…

I have a task form:

task form

I enter a task name

enter image description here

I hit (enter)plus to create it.

I get the following error that is also presented above:

enter image description here
enter image description here

If I hit refresh the task was generated ok:

enter image description here

That is why I believe it has to be in the .js.erb file…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:54:36+00:00Added an answer on June 12, 2026 at 4:54 pm
    activity_task_path(task.activity, task: task)
    

    activity_task_path expects two id parameters, I think your last is now mixed with the task: task and the post parameters. You also get mixups because of the form_for and trying this method to use ‘update’ for task. You are providing no data fields.

    So I think your solution is:

    activity_task_path(task.activity, task)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html code : <form name=uploadForm action= method=POST enctype=multipart/form-data> <input type=file
In my Ruby on Rails code, I have the following edit.html.erb file for tasks:
i have the following code to disable task manager of windows xp but it
currently I have following code: home.php <form name='myformname' id='myformid'> <input type='text' name='mytext1' value='abc'> <input
I have following code in initialization im = imread('Image02.tif'); figure(); imagesc(im); colormap(gray); [hImage hfig
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have following code for loading image from url in xml parsing endElement method
I have following code for inserting data into database using PDO. It inserts data
I have following code. ASPX Page <a href=AnyASPXPageOfWebsite.aspx onclick=javascript:CallJQuery(); > Set Price </a> JS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.