NoMethodError in Orders#new

别来无恙 提交于 2019-12-11 20:27:38

问题


I'm receiving an error when it comes to entering data into my table.

undefined method `price' for #

I was able to add the Price into my Order table, but when it comes to adding new data. I receive a, NoMethodError in Orders#new. I went into my text editor and deleted the highlighted piece of code, but the field to enter a price disappears all that is left is the title, Price.

Showing /Users/nncyvallejo90/Documents/springproject/app/views/orders/_form.html.erb where line #20 raised:

undefined method `price' for #

Extracted source (around line #20):

  <div class="field">
    <%= f.label :price %><br>
    **<%= f.text_field :price %>**
  </div>
  <div class="field">
    <%= f.label :comics_name %><br>

Trace of template inclusion: app/views/orders/new.html.erb

Schema file and it appears I don't have a migration for the last table. I do have a migration for customers and comic_books.

# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

    ActiveRecord::Schema.define(version: 20150519022610) do

  create_table "comic_books", force: :cascade do |t|
    t.string   "name"
    t.decimal  "price"
    t.string   "supplier"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "customers", force: :cascade do |t|
    t.string   "lastname"
    t.string   "firstname"
    t.string   "address"
    t.string   "city"
    t.string   "state"
    t.string   "zip"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "orders", force: :cascade do |t|
    t.integer  "customer_id"
    t.string   "comics_name"
    t.decimal  "price"
    t.integer  "quanity"
    t.decimal  "total"
    t.datetime "created_at",  null: false
    t.datetime "updated_at",  null: false
  end

end

来源:https://stackoverflow.com/questions/30316217/nomethoderror-in-ordersnew

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!