As i am new to both haml and rails , i cannot find and fix this error i am trying to create recipe application for that m creating recipecontroller and model which has `
title:string description:text
recipes_controller 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: "Sucessfully create new recipe"
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
end
_form.html.haml
= simple_form_for @recipe, html: { multipart: true } do |f|
- if @recipe.errors.any?
#errors
%p
= @recipe.errors.count
Prevented this recipe froms 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"
Here in this page only it showing syntax error
SyntaxError in RecipesController#new C:/Sites/recipehouse/app/views/recipes/_form.html.haml:14: syntax error, unexpected keyword_ensure, expecting keyword_end ...:Util.html_safe(_erbout);ensure;@haml_buffer = @haml_buffer.... ... ^ C:/Sites/recipehouse/app/views/recipes/_form.html.haml:17: syntax error, unexpected end-of-input, expecting keyword_end
Rails.root: C:/Sites/recipehouse
Aucun commentaire:
Enregistrer un commentaire