试图关注一本书,但我的表格没有生成,为什么会这样?

时间:2022-11-24 09:04:24

Trying to follow a book but my form isn't being generated, why is this? Here is my new.html.erb

试图关注一本书,但我的表格没有生成,为什么会这样?这是我的new.html.erb

<h1>New ad</h1>

<% form_for :ad,:url=>{:action=>'create'} do |f| %>
    <p><b>Name</b><br /><%= f.text_field :name %></p>

    <p><b>Description</b><br /><%= f.text_area :description %></p>

    <p><b>Price</b><br /><%= f.text_field :price %></p>

    <p><b>Seller</b><br /><%= f.text_field :seller_id %></p>

    <p><b>Email</b><br /><%= f.text_field :email %></p>

    <p><b>Img url</b><br /><%= f.text_field :img_url %></p>
    <p><%= f.submit "Create" %></p>
<% end %>

This is my ads_controller

这是我的ads_controller

class AdsController < ApplicationController
    def show
    @ad = Ad.find(params[:id])
    end

    def stats
    @seller = Seller.find(params[:id])
    end

    def index
    @ads = Ad.find(:all)
    end

    def new
    @ad = Ad.new
    end
end

and my routes is

我的路线是

resources :ads

This is all that I get

这就是我得到的一切

http://imgur.com/Zkyn9wL

1 个解决方案

#1


3  

<% form_for should be <%= form_for or the form template will not be rendered.

<%form_for应为<%= form_for,否则将不会呈现表单模板。

#1


3  

<% form_for should be <%= form_for or the form template will not be rendered.

<%form_for应为<%= form_for,否则将不会呈现表单模板。