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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:03:23+00:00 2026-06-02T07:03:23+00:00

I have a simple form view using a Rails 3.1.x application: <%= form_for(:mymodel) do

  • 0

I have a simple form view using a Rails 3.1.x application:

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

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

  <div class="field">
    Amount:
    <%= f.text_field :count %><br /><br />
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

When submit is hit here, it posts to /mymodels/new. How do I force it to go to the right create action for mymodels_controller.rb?

  • 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-02T07:03:24+00:00Added an answer on June 2, 2026 at 7:03 am

    Option 1: Follow the conventions and supply a new, unsaved record to the form_for helper. You probably already have such object on @mymodel, set on your new action of your controller. So the following snippet should work nicely:

    <%= form_for(@mymodel) do |f| %>
    

    If it does not work, you can set @mymodel on your action like this:

    class MyModelsController
      def new
        @mymodel = MyModel.new
      end
    end
    

    Option 2: Be explicit about your URL and method:

    <%= form_for(:mymodel, :url => create_mymodel_path, :method => :post) do |f| %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple search form in rails. In my search view I have
I have a nested form in a rails view that is called like this
I have simple login form I am using SQLite database which has fields like
I have a simple form created using Ajax.BeginForm : <% using (Ajax.BeginForm(Update, Description, new
I have a simple form that uploads an image to a database. Using a
Have A really simple form that isnt sending any data back to my controller.
I'm using Simple_Form with Rails 3 and it's great. I have a simple question.
I am posting a very simple form using a method I have used frequently
I have a simple form which is using ASP.NET MVC 3 unobtrusive client side
I'm using the CodeIgniter PHP framework. I have a simple form that has an

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.