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

The Archive Base Latest Questions

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

I want to keep values in forms when user create order (so if user

  • 0

I want to keep values in forms when user create order (so if user have errors in fields then user would get page with params which he/she already printed). So i do next

Controller

class OrdersController < ApplicationController
  ...

  def new
    @everpresent_field_placeholder = "Fill that"
    @order = Order.new
  end

  def create
    order = Order.new( params[:order] )

    if order.save
      flash[:success] = "Yay! Order created!"
    else
      render 'new'
      flash[:error] = order.errors.full_messages.to_sentence :last_word_connector => ", ",        
                                                             :two_words_connector => ", "
    end
  end
end

View for new order:

<legend>Order's creating</legend>

<%= form_for @order, :html => {:class => "form-horizontal"} do |f| %>
  <%= field_set_tag do %>    
    <div class="control-group">
      <%= f.label :number_of_order, "Number of order", :class => "control-label" %>

      <div class="controls">
        <%= f.text_field :number_of_order, 
                         :class => "span2",                         
                         :placeholder => @everpresent_field_placeholder %>
      </div>
    </div>

    <%= f.submit "Create", :class => "btn btn-large btn-success" %>
  <% end %>
<% end %>

But when i type something wrong in order’s number and click “Create” i get such error:

NoMethodError in Orders#create

Showing .../app/views/orders/new.html.erb where line #3 raised:

undefined method `model_name' for NilClass:Class

Extracted source (around line #3):

1: <legend>Order's creating</legend>
2: 
3: <%= form_for @order, :html => {:class => "form-horizontal"} do |f| %>
4:   <%= field_set_tag do %>    
5:     <div class="control-group">
6:       <%= f.label :number_of_order, "Number of order", :class => "control-label" %>

What do i do wrong?

  • 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:56:49+00:00Added an answer on June 2, 2026 at 7:56 am

    Calling render 'new' doesn’t call that controller method — it only renders the template associated with that action. That is, your create action never sets @order — maybe if you replace references to order with @order in your create action, that will fix things.

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

Sidebar

Related Questions

I want to have a trail that helps keep track of values I want
I have a Bash script where I want to keep quotes in the arguments
User have to populate multistep questionnaire web-forms and step messages depend on the option
I have this situation where on my main page, there are different fields and
I want to keep tabs on the number of concurrent users of my application.
I want to keep a cell selected, and only change when I select another
I want to keep SSH debug info separate (and logged) from other input. However,
I want to keep backup of my database and import it into different System?
I want to keep only numbers and remove all characters from a variable. For
I want to keep some data which is checkhed in array list. I added

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.