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

  • Home
  • SEARCH
  • 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 6629351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:14:53+00:00 2026-05-25T22:14:53+00:00

I have a resource called :school and when I call form_for(@school) it generates the

  • 0

I have a resource called :school and when I call form_for(@school) it generates the form action:

/school.1

I’m new to all this so any clues as to why it’s doing that would be much appreciated. Sleep deprived and heading for a deadline in 3 hours, arrrggg!

Thanks 🙂

routes.rb:

resource:school

school.rb:

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

      <ul>
      <% @school.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label :address1 %><br />
    <%= f.text_field :address1 %>
  </div>
  <div class="field">
    <%= f.label :address2 %><br />
    <%= f.text_field :address2 %>
  </div>
  <div class="field">
    <%= f.label :address3 %><br />
    <%= f.text_field :address3 %>
  </div>
  <div class="field">
    <%= f.label :town %><br />
    <%= f.text_field :town %>
  </div>
  <div class="field">
    <%= f.label :county %><br />
    <%= f.text_field :county %>
  </div>
  <div class="field">
    <%= f.label :postcode %><br />
    <%= f.text_field :postcode %>
  </div>
  <div class="field">
    <%= f.label :local_authority_id %><br />
    <%= f.collection_select :local_authority_id, LocalAuthority.all, :id, :name %>
  </div>
  <% if current_user.person.primary_user? %>
    <div class="field">
      <%= f.label 'Are you happy for us to send you regular updates about VRH?' %><br />
      <%= f.check_box :allow_contact %>
    </div>
  <% end %>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
  • 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-25T22:14:54+00:00Added an answer on May 25, 2026 at 10:14 pm

    by using the singular resource method you are telling rails that only one of these objects exist, in your routes file I think you need to change your resource :school to…

    resources :schools
    

    If however you do want only one school then I think you will need to add the url option to form_for…

    <% form_for(@school, :url => school_path) %>
    

    Proposed solution for follow up questions…

    I think what you need will be something like this…

    # routes.rb
    resources :users do
      resources :schools
    end
    resources :schools
    
    # app/controllers/schools_controller.rb
    class SchoolsController < ApplicationController
      def new
        @user = User.find(params[:user_id])
        @school = @user.build_school
      end
    
      def create
        @user = User.find(params[:user_id])
        @school = @user.build_school(params[:school])
        if @school.save
          # success...
        else
          # fail...
        end
      end
    
      def edit
        @school = School.find(params[:id])
      end
    
      def update
        @school = School.find(params[:id])
        if @school.update_attributes(params[:school])
          # success
        else
          # fail
        end
      end
    end
    
    # app/views/schools/new.html.erb
    <%= form_for([@user, @school]) do |f| %>
      <!-- fields go here -->
    <% end %>
    
    # app/views/schools/edit.html.erb
    <%= form_for([@user, @school]) do |f| %>
      <!-- fields go here -->
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to openRasta framework. I have a resource called Project.I have 2
I have a RESTful resource in my Rails app called Photo. I'm using Paperclip
If I have a Resource bundle property file: A.properties: thekey={0} This is a test
I have this resource file for colors <resources> <color name=CLR_BLUE>#00f</color> <color name=CLR_RED>#f00</color> <color name=CLR_GREEN>#0f0</color>
I have a resource called Book, then I have domains like: domain.com/books/272 But I
I have a RESTful Rails application with a resource called Foo. I'm trying to
Say we have a simple resource called news: resources :news The generated paths are
I have a subscriber resource (mailinglist) and want to make a unsubscribe form. I
I have model called Search and a resource named :search . I'd like to
I have a REST resource called Greetings. Here is my routes file: resources :greetings

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.