1
を使用して、データベース内のラジオボタンの選択を保存します。これは私のコントローラである:どのようにレール
class ReportNeedsController < ApplicationController
def index
@report_needs = nil
end
def new
@report_need = ReportNeed.new
end
def create
@report_need = ReportNeed.new(params[:report_need])
@report_need.save
redirect_to @report_need
end
end
は、この私のnew.hamlファイルされる:
はなぜあなたが報告したいですか? PRODUCT_TYPEは、テーブルのフィールドreport_needsは、あなたの行動に変更する必要がない場合、コントローラで
%input{:type => "radio", :name => "report_need[product_type]", :id => "report_need[product_type]-1", :value => "salesforce", :checked => true}
%br/
%input{:type => "radio", :name => "report_need[product_type]", :id => "report_need[product_type]-2", :value => "salesforce", }
:
%form
%input{:name => "option", :type => "radio", :value => "spam"}
spam
%br/
enter code here
%input{:name => "option", :type => "radio", :value => "product_corrupted"}
product_corrupted
%br/
%input{:name => "option", :type => "radio", :value => "product_spoiled"}
product_spoiled