我的简单表格不是在做 POST。我一直在看这个,但看不出有什么问题(我确定它在我的路线中)。这是我所拥有的:
看法:
views/buyers/new.html.erb
<%= form_for(@buyer) do |f| %>
<%= f.text_field :phone %><br />
<%= f.text_field :make %><br />
<%= f.text_field :model %><br />
<%= f.submit %>
<% end %>
控制器:
BuyersController
def new
@title = "Welcome to Car Finder"
@buyer = Buyer.new
end
def create
@buyer = Buyer.new(params[:buyer])
if @buyer.save!
redirect_to success
else
redirect_to :back
end
end
路线:
resources :buyers
耙路线:
buyers GET /buyers(.:format) buyers#index
POST /buyers(.:format) buyers#create
new_buyer GET /buyers/new(.:format) buyers#new
edit_buyer GET /buyers/:id/edit(.:format) buyers#edit
buyer GET /buyers/:id(.:format) buyers#show
PUT /buyers/:id(.:format) buyers#update
DELETE /buyers/:id(.:format) buyers#destroy
当我提交表单时,它停留在同一页面上,永远不会进入创建操作。以下来自日志
Started GET "/?..[params]..."
Processing by BuyersController#new as HTML
谢谢你提供的所有帮助