[英]How can i map the data from controller in Ruby on Rails
in create page view , 在创建页面视图中,
I have a radio button like this, 我有一个单选按钮,
<%=radio_button_tag(:repeat, "1")%><%=f.label("None")%>
<%=radio_button_tag(:repeat, "2")%><%=f.label("Start Now")%>
<%=radio_button_tag(:repeat, "3")%><%=f.label("Daily")%>
<%=radio_button_tag(:repeat, "4")%><%=f.label("Weekly")%>
<%=radio_button_tag(:repeat, "5")%><%=f.label("Monthly")%>
and if i submit, it sends like this. 如果我提交,它会像这样发送。
Parameters: {"utf8"=>"✓", "authenticity_token"=>"jJP/GZxllRLV2q/gENb0raCVhKPlASPdc+f6hqP23dE=", "appointment"
=>{"appointmentname"=>"test for repeat daily first", "description"=>"daily "}, "repeat"=>"3", "start_date"=>"20
14-03-13", "start_time"=>"16:00", "end_time"=>"17:00", "repeat_time"=>"19", "roomType"=>"1", "bb_state_id"=>"10
7", "jNameTimeZone"=>"Etc/GMT", "invited_radio_btn"=>"1", "numberOfParticipants"=>"1", "moderatorId"=>"1", "att
endee_list"=>[{"id"=>"1", "email"=>"hyunjae.park@access-company.com", "firstname"=>"hyunjae", "lastname"=>"park
"}]}
as you can see, the parameter "repeat"=>"3"
is there. 如您所见,参数
"repeat"=>"3"
在那里。
ok, i saved this to the database. 好的,我将其保存到数据库中。
now, i want to edit this page. 现在,我要编辑此页面。
from the controller it sends the param like this. 从控制器发送这样的参数。
@repeat
If i print this with logger.debug. 如果我用logger.debug打印。 it shows what i have chosen(1~5 value)
它显示了我选择的值(1〜5值)
now, with this parameter 现在,使用此参数
in the view, i have to map the radio_button which has been chosen when the room was created. 在视图中,我必须映射在创建房间时选择的radio_button。
But it doesn't matches it :( 但它不匹配:(
What is my problem in here??? 我在这里有什么问题???
Something like this: 像这样:
<%= form_for @post do |f| %>
<%= f.collection_radio_buttons :repeat, [[1, 'none'], [2, 'start now']], :id %>
<%= f.submit %>
<% end %>
within the form http://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-collection_radio_buttons 在表格http://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-collection_radio_buttons中
or without a form: http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_radio_buttons 或不使用表单: http : //api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_radio_buttons
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.