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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:51:28+00:00 2026-05-15T20:51:28+00:00

In Rails 3 edge, I have set up two nested resources like this: config/routes.rb

  • 0

In Rails 3 edge, I have set up two nested resources like this:

config/routes.rb

resources :agencies do
   resources :properties
end

I use Mongomapper as my ORM, and when I try to create a new property under an existing agency, I get this error:

---> http://localhost:3000/agencies/4c3ff0f455899f0fb5000001/properties/new

NoMethodError in Properties#new

Showing /Users/peter/programming-MacBookPro/iPhone/inspector-on-rails/app/views/properties/_form.html.erb where line #1 raised:

undefined method `properties_path' for #<#<Class:0x00000100dae020>:0x00000100d97f00>
Extracted source (around line #1):

1: <%= form_for @property do |f| %>
2: <% if @property.errors.any? %>
3:    <div id="error_explanation">
4:      <h2><%= pluralize(@property.errors.count, "error") %> prohibited this property from being saved:</h2>
Trace of template inclusion: app/views/properties/new.html.erb

Rails.root: /Users/peter/programming-MacBookPro/p-on-rails

Application Trace | Framework Trace | Full Trace
app/views/properties/_form.html.erb:1
app/views/properties/new.html.erb:3
app/controllers/properties_controller.rb:29:in `new'
Request

Parameters:

{"agency_id"=>"4c3ff0f455899f0fb5000001"}

In properties_controller.rb:

def new
    @property = Property.new

    respond_to do |format|
      format.html # new.html.erb
      format.json  { render :json => @property }
    end
end

in app/views/properties/_form.html.erb:

<%= form_for @property do |f| %>
<% if @property.errors.any? %>
   <div id="error_explanation">
     <h2><%= pluralize(@property.errors.count, "error") %> prohibited this property from being saved:</h2>

     <ul>
     <% @property.errors.full_messages.each do |msg| %>
       <li><%= msg %></li>
     <% end %>
     </ul>
   </div>
 <% end %>
 <div class="field">
     <%= f.label :address_postcode %><br />
     <%= f.text_field :address_postcode %>
   </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

In app/views/properties/new.html.erb:

<h1>New property</h1>
<%= render 'form' %>
<%= link_to 'Back', @property %>

I suspect that the error about properties_path not being defined has something to do with the nesting of the properties resource under agencies. However, I can’t figure out how to deal with the complain in line 1 of _form.html.erb as something like form_for (@agency, @property) doesn’t work.

Any ideas?

  • 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-05-15T20:51:29+00:00Added an answer on May 15, 2026 at 8:51 pm

    according to your route, property is nested under agency, right?

    to avoid errors, you can follow this way:

    step1- in controller, in ‘new’ action, instantiate @property object as:

    @property = Property.new(:agency_id => params[:agency_id]) # this will have agency association from beginning
    

    step2- in _form.html.erb use this:

    form_for (@property.agency,@property)
    

    this code should work for sure (I use it often), don’t know if there’s a cleaner/less-ugly solution 😉

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

Sidebar

Related Questions

As my understanding on nested resources, on edge Rails, should not link_to 'User posts',
My Gem file looks like this: source 'http://rubygems.org' gem 'rails', '3.0.0' # Bundle edge
[Rails] Where to put this code? I have a user1 and when another registered
how do I install the latest, unreleased version of rails? i.e. edge rails? have
I've got a form with nested objects as described here: http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes It's working fine,
I was reading about scoped mass assignment in Rails 3.1 (Edge). I found this
I am trying to use FactoryGirl instead of default fixtures in edge Rails 3.
Here is my gemfile: source 'https://rubygems.org' gem 'rails', '3.2.2' # Bundle edge Rails instead:
Rails has a nice idiom that makes it easy for you to have a
Rails: I need to set a condition in a has_many that needs the self.id

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.