Created
January 22, 2025 21:30
-
-
Save mfifth/eaf89dded62fab0a3bef18fb74398184 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/app/views/surveys/create_answer.js.erb | |
$("#survey-#{@survey.id}").html("<div><p>You have submitted the form successfully!</p></div>"); | |
alert('what the fuck'); | |
console.log('why is this working.'); | |
# Controller action | |
def create_answer | |
@survey = Survey.find(params[:survey_id]) | |
@survey.answers.create(agree: params[:agree]) | |
respond_to do |format| | |
format.js { render layout: false } | |
end | |
end | |
# Form tag from view | |
<div class="survey-answers" id=<%= "Survey-#{survey.id}" %>> | |
<%= form_tag('/create_answer', multipart: true, local: false, remote: true, method: :post) do %> | |
<%= label_tag "Do you agree?" %> | |
<%= radio_button_tag :agree, true, 'checked' %> | |
<%= label_tag "Do you disagree?" %> | |
<%= radio_button_tag :agree, false, 'checked' %> | |
<%= hidden_field_tag :survey_id, survey.id %> | |
<%= submit_tag 'Submit' %> | |
<% end %> | |
</div> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment