1

현재 레일에 루비를 사용하는 레서피 박스 응용 프로그램에서 작업 중입니다. 나는 새로운 요리법을 만들 때 그것은 말한다Ruby에서 NoMethodError가 발생하는 이유는 무엇입니까?

이 내 form.html.haml

= simple_form_for @recipe, html: { multipart: true } do |f| 
    - if @recipe.errors.any? 
     #errors 
      %p 
       = @recipe.errors.count 
       Prevented this recipe from saving 
      %ul 
       - @recipe.errors.full_messages.each do |msg| 
        %li= msg 
    .panel-body 
     = f.input :title, input_html: { class: 'form-control' } 
     = f.input :description, input_html: { class: 'form-control' } 

    = f.button :submit, class: "btn btn-primary" 
이다 '제목'

= f.input :title, input_html: { class: 'form-control' } 

에 대한

정의되지 않은 메서드

그리고이 내 r ecipes_controller.rb

class RecipesController < ApplicationController 
before_action :find_recipe, only: [:show, :edit, :update, :destroy] 

def index 
end 

def show 
end 

def new 
    @recipe = Recipe.new 
end 

def create 
    @recipe = Recipe.new(recipe_params) 

    if @recipe.save 
     redirect_to @recipe, notice: "Toll! Neues Rezept erfolgreich erstellt." 
    else 
     render 'new' 
    end 
end 

private 

def recipe_params 
    params.require(:recipe).permit(:title, :description) 
end 

def find_recipe 
    @recipe = Recipe.find(params[:id]) 
end 

당신은 '새로운'보기에서 양식을 렌더링해야
+0

'recipes' 테이블을위한 DB 스키마 나'recipes' 테이블을 생성 한 이전 파일 (그리고 후속 수정)을 게시 할 수 있습니까? – ArtOfCode

+1

DB의'recipes' 테이블에'title' 칼럼이없는 것 같습니다. –

답변

1
  1. 당신은 당신의 DB에 열의 제목을 '이 있어야

우리를보기 'debug @recipe'가 출력하는 것은 'title'속성입니까?

관련 문제