2016-08-31 9 views
1

私は次の問題があります。ライン#40を上昇/Users/felipevelasquez/Desktop/APPS/meetrico2/meetrico-production/app/views/item_categories/_form.html.hamlを表示NoMethodError

37: %p 
38:  = f.label :cupon_code, "Codigo de cupon" 
39:  %br/ 
40:  = f.text_field :cupon_code 
41: %p.columns 
42:  = f.label :num_tables, "No. Prod:" 
43:  %br/ 

テンプレートインクルージョンのトレース:アプリケーション/ビュー/ item_categori:#

(回線#40程度)

抽出されたソース用

未定義のメソッド `cupon_code」 es/new.html.haml

Rails.root:/ Users/felipevelasquez/Desktop/APPS/meetrico2/meetrico-production アプリケーショントレース|フレームワークトレース|完全なトレース

アプリ/ビュー/ item_categories/_form.html.haml:40:block in _app_views_item_categories__form_html_haml__1368949097161944936_70115358072760' app/views/item_categories/_form.html.haml:1:in _app_views_item_categories__form_html_haml__1368949097161944936_70115358072760' で:4: アプリ/ビュー/ item_categories/new.html.haml _app_views_item_categories_new_html_haml__3526667596950049714_70115303712400' config/initializers/quiet_assets.rb:13:in call_with_quiet_assetsの

リクエスト

パラメータ:

なし

ショーセッションダンプ

ショーのenvダンプ 応答

ヘッダ:

なし

私は私のdb cupon_codeでフィールドを作成し

、ここに私のスキーマは次のとおりです。ここで

create_table "transactions", :force => true do |t| 
    t.integer "order_id" 
    t.string "action" 
    t.integer "amount" 
    t.boolean "success" 
    t.string "authorization" 
    t.string "message" 
    t.text  "params" 
    t.datetime "created_at", :null => false 
    t.datetime "updated_at", :null => false 
    t.integer "cupon_code" 

は誰もが見ることができます問題?

これは、穴の形である:

= form_for @item_category, html: { class: 'upload-file-or-text'} do |f| 
    %p 
    = f.label :coworking_space, "Coworking Space" 
    %br/ 
    = select_tag "item_category[coworking_space_id]", options_from_collection_for_select(@coworking_spaces, "id", "name", @item_category.coworking_space_id) 
    %p 
    = f.label :name, "Nombre" 
    %br/ 
    = f.text_field :name, :required=>"required",:title=>"Este campo es obligatorio" 
    %p.columns 
    = f.label :image_text_url, "Url de Imagen o Icono" 
    %br/ 
    = f.text_area :image_text_url, :size => "40x4", class: 'image-text' 
    %p.columns 
    = f.label :image_file, "O sube una imagen" 
    - if @item_category.image_file? 
     %br/ 
     = image_tag @item_category.image_url, class: 'image-thumb' 
     %label 
     = f.check_box :remove_image_file, class: 'remove-ckeck' 
     Eliminar image? 
    %br/ 
    = f.file_field :image_file, class: 'image-file' 
    %p.alert-message.hide 
    Debe elegir alguna de estas opciones 
    %p 
    = f.label :description, "Descripción" 
    %br/ 
    = f.text_area :description, :size => "40x4" 
    %p 
    = f.label :notification_body, "Cuerpo de Notificacion" 
    %br/ 
    = f.text_area :notification_body, :size => "40x4" 
    %p 
    = f.check_box :promo_header 
    Línea de Producto de la cabecera 
    %p 
    = f.label :cupon_code, "Codigo de cupon" 
    %br/ 
    = f.text_field :cupon_code 
    %p.columns 
    = f.label :num_tables, "No. Prod:" 
    %br/ 
    = f.text_field :num_tables 
    %p.columns 
    = f.label :reserved, "Reservas:" 
    %br/ 
    = f.text_field :reserved 
    %p 
    = f.label :normal_price, t(:normal_sale_price) 
    %label 
     = "en #{@item_category.coworking_space.city.currency.name rescue " "}" 
    %br/ 
    = f.text_field :normal_price 
    %p.columns 
    = f.label :green, "Green:" 
    %label 
     = "en #{@item_category.coworking_space.city.currency.name rescue " "}" 
    %br/ 
    = f.text_field :green 
    %p.columns 
    = f.label :green, "Yellow:" 
    %label 
     = "en #{@item_category.coworking_space.city.currency.name rescue " "}" 
    %br/ 
    = f.text_field :yellow 
    %p.columns 
    = f.label :green, "Red:" 
    %label 
     = "en #{@item_category.coworking_space.city.currency.name rescue " "}" 
    %br/ 
    = f.text_field :red 
    %p 
    = f.label :target_url, t(:target_url) 
    %br/ 
    = f.text_field :target_url 
    %p= f.submit 
+0

フォーム全体を投稿できますか? – Ruslan

+0

あなたはcuponコードを追加するために移行を作成して実行しましたか? – Felix

+0

はい、私はテーブルトランザクションで行いました。これは私がやったことです:レールはマイグレーションを生成しますAddCuponCodeColumnToTransactions cupon_code:整数 – user2284348

答えて

0

は@item_categoryの取引の一部ですか? @item_categoryオブジェクト内のすべての属性は、form_for内でのみ使用できます。トランザクションの属性が@item_categoryからアクセス可能に設定されていない場合、トランザクションの属性は機能しません。

希望すると助かります!

+0

私は、属性がトランザクションがアイテムカテゴリに属していると言う必要がありますか? – user2284348

+0

はい...取引が商品カテゴリに属する​​場合、取引モデルでは「belongs_to」にする必要があります。最後に、アイテムカテゴリに多数のトランザクションがある場合、アイテムカテゴリモデル( 'has_many:transactions')に明示的に指定する必要があります。 – roadev