我這_form.html.erb:ROR3:hidden_field安全
<%if current_user.role_id == 1 %>
<div class="combo_box">
<%= f.label :subscriber %>
<%= f.collection_select(:user_id, User.all,:id,:name,{:include_blank=>false}, :class => 'styled') %>
</div>
<div class="combo_box">
<%= f.label :group %>
<%= f.grouped_collection_select(:group_id, User.all,:support_agent_groups,:name,:id,:name, {:prompt => "-- Select a group --"}, :class => 'styled') %>
</div>
<div class="combo_box">
<%= f.label :role %>
<%= f.collection_select(:role_id, Role.all,:id,:name,{:include_blank=>false}, {:class => 'styled'}) %>
</div>
<div class="combo_box">
<%= f.label :subscription %>
<%= f.collection_select(:subscription_id, Subscription.all,:id,:name, {:prompt => "-- Select a subscription --"}, {:class=>'styled'}) %>
</div>
<% elsif current_user.role_id == 6 && @user.role_id != 6 %>
<%= f.hidden_field :user_id, :value => current_user.id %>
<%= f.hidden_field :subscription_id, :value => current_user.subscription_id %>
<div class="combo_box">
<%= f.label :group %>
<%= f.collection_select(:group_id, SupportAgentGroup.where(:user_id => current_user.id),:id,:name, {:prompt => "-- Select a group --"}, :class => 'styled') %>
</div>
<div class="combo_box">
<%= f.label :role %>
<%= f.collection_select(:role_id, Role.where('id <> ?', 1).where('id <> ?', 6),:id,:name,{:include_blank=>false}, {:class => 'styled'}) %>
</div>
<% elsif current_user.role_id == 6 %>
<%= f.hidden_field :user_id, :value => current_user.id %>
<%= f.hidden_field :role_id, :value => current_user.role_id %>
<%= f.hidden_field :subscription_id, :value => current_user.subscription_id %>
<div class="combo_box">
<%= f.label :group %>
<%= f.collection_select(:group_id, SupportAgentGroup.where(:user_id => current_user.id),:id,:name, {:prompt => "-- Select a group --"}, :class => 'styled') %>
</div>
<% else %>
<%= f.hidden_field :user_id, :value => current_user.user.id %>
<%= f.hidden_field :group_id, :value => current_user.group_id %>
<%= f.hidden_field :subscription_id, :value => current_user.user.subscription_id %>
<%= f.hidden_field :role_id, :value => current_user.role_id %>
<% end %>
,我可以查看所有隱藏與檢查,在瀏覽器螢火選項元素值作爲申請
<input id="user_user_id" type="hidden" value="2" name="user[user_id]" />
我可以在其中改變數值2
到100/200/....
and on submint the new value 100/200/...
is posted fo保存到數據庫並保存在數據庫中。
我需要檢查所有在視圖中的條件,並在控制器中找到合適的默認值..或任何使用hidden_filed選項來解決此安全問題。
感謝您的幫助......