Ich habe jetzt ein Formular mit 4 text_fields und nur die untere fügt die Daten tatsächlich dem Modell hinzu? Alle text_fields sind identisch und für das Leben von mir kann ich nicht herausfinden, warum sie alle nicht gleich funktionieren. Hier ist mein Code hoffentlich wird jemand eine einfache Antwort haben?Form_for helpers - Schienen
class ResponsesController < ApplicationController
def new
@response = Response.new
end
def create
@response = Response.new(response_params)
if @response.save
flash[:notice] = "Response has been edited"
redirect_to new_response_path(:response)
else
render "new"
end
end
private
def response_params
params.require(:response).permit(:message)
end
das ist meine Ansicht
<div class="container">
<div class="row">
<h3 class="text-center">Edit The Bounce Back Response</h3>
<div class="col-lg-8 col-lg-offset-2 well">
<%= form_for @response do |form| %>
<div class="form-group">
<%= form.label :message, "Visitor:", class: "response_label"%>
<%= form.text_field :message, class: "form-control", placeholder: "Change Visitor Response!" %>
</div>
<div class="form-group">
<%= form.label :message, "Staff:", class: "response_label"%>
<%= form.text_field :message, class: "form-control", placeholder: "Change Staff Response!" %>
</div>
<div class="form-group">
<%= form.label :message, "Volunteeer:", class: "response_label"%>
<%= form.text_field :message, class: "form-control", placeholder: "Change Volunteer Response!" %>
</div>
<div class="form-group">
<%= form.label :message, "Dance:", class: "response_label"%>
<%= form.text_field :message, class: "form-control", placeholder: "Change Dance Response!" %>
</div>
<%= form.submit "Update", class: "btn btn-primary" %>
<% end %>
</div>
Wenn Sie im unteren Textfeld eingeben und es wird tatsächlich geben die Daten-Nachricht verwenden, wenn Sie eine andere Textfeld meine Konsole zurück ist dies
u kann Ihre 'responses_controller.rb' Datei schreiben? – 7urkm3n
wo sind deine 'edit and update' Methoden? ist auch Ihr form_for in '_form.html.erb'? – 7urkm3n
Ich bin noch nicht dort, ich will nur sie text_field, um die Daten in das Modell eingeben – Bitwise