###前提・実現したいこと
rubu on railsで下にあるコードを書きました。radiobuttonにはhahaha
、hehehe
しか設定できなくしました。ですが、デベロッパーツールでradiobuttonの値を変えてpostすると、その変えた値が表示されてしまいます。どうすればradiobuttonの値をhahahaとheheheの2つの値に絞ることができますか?ruby on railsの機能でそういうものはないですか?
よろしくお願いします。
###該当のソースコード
index.html.erb
<h1><%= @title %></h1> <p><%= @msg %></p> <%= form_tag(controller: "helo", action: "index") do %> <%= radio_button_tag("radiobutton", "hahaha") %> <%= label_tag("radiobutton_hahaha", "radio_button1") %> <%= radio_button_tag("radiobutton", "hehehe") %> <%= label_tag("radiobutton_hehehe", "radio_button2") %> <%= submit_tag("Click") %> <% end %>
routes.rb
Rails.application.routes.draw do get "helo/index", to: "helo#index" post "helo/index", to: "helo#index" end
helo_controller.rb
class HeloController < ApplicationController def index @title = "index" if request.post? if params["radiobutton"] @msg = params["radiobutton"] else @msg = "not checked!" end else @msg = "hello" end end end
###試したこと
課題に対してアプローチしたことを記載してください
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。