Hi im pretty new to ruby on rails and hope to find some help. I try to do a simple form (gem) that renders in the "/New"-page to create a Competition. i found some similar questions. and i have no ide, whats wrong, i feel sorry if this is a bad question :) but id be happy if somone could help me.
thats the page, you find under url/competitions/new new.html.erb
<h1>new competition</h1>
<%= render 'form' %>
it should render following form into the index file _form.html.erb
<%= simple_form_for @comp do |f| %>
<%= f.input :title, label: "Competition Title" %>
<%= f.input :description %>
<%= f.input :author %>
<%= f.button :submit%>
relevant code: comp.rb (model) got created with:
rails g model comp title:string description:text author:string
class Comp < ActiveRecord::Base
end
competitions_controller.rb
class CompetitionsController < ApplicationController
def inedx
end
def new
@comp = Comp.new
end
def create
@comp = Comp.new(comp_params)
end
private
def comp_param
params.require(:comp).permit(:title, :description, :author)
end
end
if i try to load the new.html.erb file url/competitions/new (should give me a bootstrap form, where i can put in the params)
instead i get this error:
undefined method `comps_path' for #<#:0x007ff9ba36c2c8> Did you mean? competitions_path
Extracted source (around line #1): Trace of template inclusion: app/views/competitions/new.html.erb
i would be very happy if somone could help a beginner, if u need more information leave a comment
Aucun commentaire:
Enregistrer un commentaire