Sai Ch
2014-Sep-26  12:19 UTC
how to asign strong perameters using radio button checked value in rails
please help me to assign strong params
myapplication view:
<div style="margin:1% 0">
        <%= f.label :choose  %>
        <span id="upload">
          <%= f.radio_button :choice, "1" %>
          <%= f.label :choice, "New Presentation", :value =>
"1", :style
=> 'margin: -18px 25px 0' %>
        </span>
        <span id="select">
        <%= f.radio_button :choice, "0" %>
        <%= f.label :choice, "Select Presentation", :value =>
"0",
:style => 'margin: -18px 25px 0' %>
      </span>
      </div>
      <div id="upload_pre" style="display: none; margin:
1%">
        <%= f.file_field :ppt %>
      </div>
      <div id="selection_pre" style="display: none; margin:
1%">
      <%= f.select :presentation_id,
options_for_select(current_user.presentations.collect {|s|
[s.avatar_file_name,s.id]}), :prompt => "Please select your
Presentation"  %>
 </div>
Myapplication webnaircontroller:
def create
@webnair = Webnair.new( webnairs_params )
  def webnairs_params
    if choice == 1
    params.require(:webnair).permit(:user_id, :ppt, :choice, :title,
:description)
    else
    params.require(:webnair).permit(:user_id, :presentation_id, :choice,
:title, :description)
   end
end
end
-- 
Posted via http://www.ruby-forum.com/.
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/443c1c58d922c0864659aec80b348b42%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.