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 8955805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:38:10+00:00 2026-06-15T14:38:10+00:00

What i have: Routes: resources :tests do resources :resultsets, :only => [:create, :destroy] resources

  • 0

What i have:

Routes:

resources :tests do
  resources :resultsets, :only => [:create, :destroy]
  resources :testresults, :only => [:edit, :update] do
    resources :testnotes, :only => [:create, :update, :destroy]
  end
end

Submitted form: (No additional variables)

<%= form_for [@session, @testresult, @testnote], :remote => true do |f| %>
  <%= f.text_field :line %>
<% end %>

@session is a Test
@testresult is a Testresult
@testnote = Testnote.new

Controller Actions:

def create
  @testresult = Testresult.find(params[:testresult_id])
  @testnote = Testnote.find_or_create_by_line(params[:testnote][:line])
  @connection = Testnoteconnection.find_or_initialize_by_testnote_id_and_testresult_id(@testnote.id, @testresult.id)

  respond_to do |format|
    if @connection.new_record? and @connection.save
      format.js
    else
      format.js { render :partial => 'error' }
    end
  end
end

def update
  @testresult = Testresult.find(params[:testresult_id])
  @testnote = Testnote.find(params[:id])
  @connection = Testnoteconnection.find_or_initialize_by_testnote_id_and_testresult_id(@testnote.id, @testresult.id)

  respond_to do |format|
    if @connection.new_record? and @connection.save
      format.js
    else
      format.js { render :partial => 'error' }
    end
  end
end

What is the error:

Everything, but the response, is working fine. The database is working correctly and the entries are being created as they should. But the browser throws me the following error:

No route matches {:action=>"update", :controller=>"testnotes", :test_id=>nil, :testresult_id=>#<Testresult id: 13, resultset_id: 4, testobjecttype_id: 114, testtype_id: 1, result: nil, randomed_order: 0, created_at: "2012-11-28 16:22:49", updated_at: "2012-11-28 16:22:49">, :id=>#<Testnote id: 10, line: "asdf", created_at: "2012-12-05 16:06:17", updated_at: "2012-12-05 16:06:17">}

My thoughts:

Short: I have absolutly no idea!
Obviously the routing is fine, else the server would not even reach the controller action and do those database entries. But what is creating the second routing request? And why isn’t the respons being rendered correctly?

Edit:
The form is submitting correctly and being routed properly to the create action, which is being called correctly aswell. And everything works until format.js. Could the problem be in the view?

Edit2: (View and partial)

Create.js

$('#notes_drop').closest('tr').before('<%= j render :partial => "testnotes/testnote", :locals => {:note => @testnote} %>');

testnotes/testnote partial

<tr id='comment_<%= dom_id(note) %>'>
  <td>
    <%= note.line %>
  </td>
  <td>
    <%= link_to 'delete', test_testresult_testnote_path(@session, @testresult, note), :method => :delete, :remote => true %>
  </td>
</tr>
  • 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-15T14:38:11+00:00Added an answer on June 15, 2026 at 2:38 pm

    Update: Your view includes the line
    test_testresult_testnote_path(@session, @testresult, note)

    Since @session is nil, the Rails router can’t figure out how to generate the test_testresult_testnote_path.

    Original answer below.

    My guess is that your view code for format.js includes code that is trying to find a particular route. Maybe your js view code is trying to render the form partial?

    In any case, if you look at

    No route matches {:action=>"update", :controller=>"testnotes", :test_id=>nil, :testresult_id=>#<Testresult id: 13, resultset_id: 4, testobjecttype_id: 114, testtype_id: 1, result: nil, randomed_order: 0, created_at: "2012-11-28 16:22:49", updated_at: "2012-11-28 16:22:49">, :id=>#<Testnote id: 10, line: "asdf", created_at: "2012-12-05 16:06:17", updated_at: "2012-12-05 16:06:17">}
    

    You’ll notice that :test_id =>nil, which means that you’re not passing a Test instance for routing. Since your :testnotes are defined as a nested resource under :testresults, which is nested under :tests, you will have to pass a non-nil instances of TestResult and Test in order to generate a route correctly.

    Are you instantiating the @session variable in a before_filter? If not, try instantiating @session in your update action, and see if that fixes your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In routes.rb i have: resources :themes do resources :messages end In messages_controller_test.rb i have:
I have routes listed as follows resources :jobs do resources :invoices, :only => [:show]
I have routes structure: namespace :admin do resources :currencies end rake routes output: admin_currencies
in my routes.rb I have: resources :boards do resources :items end now in boards#show
i have routes, resources :categories do resources :products end How can i check the
In my routes I have: resources :accounts This produces: accounts GET /accounts(.:format) accounts#index POST
When defining a resources in routes.rb in Rails, I have the following problem: My
In my routes I currently have resources :users and so I get the routes
In my routes.rb I have this: map.namespace :admin do |admin| admin.resources :galleries do |galleries|
I am attempting to get rails routes paths via nested resources. I have looked

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.