Ich habe modellbasierte Form:Unable Modell basierte Formulare erstellen Schienen 4
<h2>Add New Credit Card</h2>
<%= form_for @credit_card do |f| %>
some fields
<% end %>
Routen:
resources :credit_card
credit_card_index GET /credit_card(.:format) credit_card#index
POST /credit_card(.:format) credit_card#create
new_credit_card GET /credit_card/new(.:format) credit_card#new
edit_credit_card GET /credit_card/:id/edit(.:format) credit_card#edit
credit_card GET /credit_card/:id(.:format) credit_card#show
PATCH /credit_card/:id(.:format) credit_card#update
PUT /credit_card/:id(.:format) credit_card#update
DELETE /credit_card/:id(.:format) credit_card#destroy
Controller:
def new
@credit_card = CreditCard.new
end
Wenn ich von Form zu machen, versuchen Sie es sagt:
undefined method `credit_cards_path' for #<#<Class:0x00000004c37680>:0x00000004c34570>
Did you mean? credit_card_path
credit_card_index_path
credit_card_url
Es ist eine modellbasierte Form, für jetzt habe ich nichts im Modell. Ich möchte nur rendern und übermitteln wird gehen zu erstellen Methode
was ist das: 'resources: credit_history'? – LearningROR
Alles hängt davon ab, was Sie brauchen. Ich habe auch die Links zur Dokumentation gepostet, also sieh es dir an. – Vucko