[RUBY] Install multiple submit buttons in Rails View to get the value of the pressed button

Thing you want to do

Install multiple buttons and get the value of the pressed button as shown below

View Jump to the purpose action of the select controller


<%= form_tag({ :controller => 'select', :action => 'purpose' }) do %>
        <%= submit_tag "A" %><br> 
        <%= submit_tag "B" %><br>
        <%= submit_tag "C" %><br>
        <%= submit_tag "D" %><br>       
<% end %>


The value of the button is entered in params [: commit]


class SelectController < ApplicationController   
    def purpose
        #A,B,C,Enter the value of the button such as D

Recommended Posts

Install multiple submit buttons in Rails View to get the value of the pressed button
Get the value of enum saved in DB by Rails with attribute_before_type_cast
[Rails] Button to return to the top of the page
I want to get the value in Ruby
[Java] How to get the maximum value of HashMap
[Rails] How to get the contents of strong parameters
[Rails] How to display an image in the view
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
[Rails] Where to be careful in the description of validation
[Rails] How to display information stored in the database in view
[Ruby on Rails] I want to get the URL of the image saved in Active Storage
How to install JavaScript library "select2" that makes multiple selections of selectbox fashionable in Rails 6.0
[Rails] How to get the URL of the transition source and redirect
[Webpacker] Summary of how to install Bootstrap and jQuery in Rails 6.0
[Note] What to do if bundle install in Chapter 3 of the rails tutorial is not possible
I tried to make the "Select File" button of the sample application created in the Rails tutorial cool
[Rails] Talk about paying attention to the return value of where
How to get the id of PRIMAY KEY auto_incremented in MyBatis
How to get boolean value with jQuery in rails simple form
I want to change the value of Attribute in Selenium of Ruby
[Android] I want to get the listener from the button in ListView
How to get the length of an audio file in java
How to increment the value of Map in one line in Java
How to write the view when Vue is introduced in Rails?
How to install Swiper in Rails
[Rails + Webpacker] I want to use images of assets! Until you can view the image in Vue.js
How to decorate the radio button of rails6 form_with (helper) with CSS
The problem that the contents of params are completely displayed in the [Rails] view
Procedure to make the value of the property file visible in Spring Boot
[Rails] How to get the user information currently logged in with devise
[Rails] Use devise to get information about the currently logged in user
How to get the value after "_" in Windows batch like Java -version
How to get the setting value (property value) from the database in Spring Framework
How to change the value of a variable at a breakpoint in intelliJ
How to get the absolute path of a directory running in Java
[Rails] The cause of not being able to post was in form_with
Android development, how to check null in the value of JSON object
How to create your own annotation in Java and get the value
Change the save destination of the image to S3 in the Rails app. Part 2
Get the result of POST in Java
How to get the date in java
The process of introducing Vuetify to Rails
[Swift] How to get the number of elements in an array (super basic)
[swift] How to control the behavior when the back button of NavigationBar is pressed
Decompose "$ printf" install: --no-document \ nupdate: --no-document \ n ">> ~ / .gemrc" in Chapter 1 of the Rails Tutorial
graphql-ruby: How to get the name of query or mutation in controller Note
I want to get the value of Cell transparently regardless of CellType (Apache POI)
How to get the ID of a user authenticated with Firebase in Swift
[Rails] How to register multiple records in the intermediate table with many-to-many association
Create your own shortcuts in Xcode to eliminate the hassle of pod install
[Rails] How to get rid of flash messages in a certain amount of time
How to make a unique combination of data in the rails intermediate table
Sample code to get the values of major SQL types in Java + MySQL 8.0
[Order method] Set the order of data in Rails
I tried to organize the session in Rails
How to get today's day of the week
How to use JQuery in js.erb of Rails6
[Ruby on Rails] How to install Bootstrap in Rails
[Java] How to get the authority of the folder
How to check Rails commands in the terminal
Rails The concept of view componentization of Rails that I want to convey to those who want to quit