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

please anybody give me some solution.......?

Is choice method defined anywhere ? >>>> " if choice == 1 "

And keep your permitted params method outside create. def create

end

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

Vivek Sampara wrote in post #1158513:

Is choice method defined anywhere ? >>>> " if choice == 1 "

And keep your permitted params method outside create. def create

end

  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

yes I've created strong perams outside create. No I don't create anywhere choice method but i get choice value from form tag i.e

<%= f.radio_button :choice, "1" %> <%= f.label :choice, "New Presentation", :value => "1" %>

<%= f.radio_button :choice, "0" %> <%= f.label :choice, "select Presentation", :value => "0" %>

if you should check it like

if params[:choice].to_s == “1” #do something

else

#do something else end

Vivek Sampara wrote in post #1158518:

if you should check it like

if params[:choice].to_s == "1"   #do something else   #do something else end

sorry Bro it won't work....

That does not make a variable called choice available in the controller action, it should make it availble via the params hash though. Check in development.log to check whether it is being passed ok and put some debug in your code to see what is happening.

Colin

What do you mean it won't work? If you don't give us details of what is happening then we cannot help. We are not telepathic.

Colin