0
votes

My f.select is not working this is my form -

  - @anonymous.each do |a|
   =form_for @confession , html: {multipart: true} do |f|
    =f.label :Confess
    =f.text_area :confession , require: true
    =f.label :post_as
    =f.select(:postid,options_for_select([[@confession.amitian.fullname,@confession.amitian.fullname],[a.fullname,a.fullname]]))
    =f.file_field :confessionimage
    =f.submit 'Confess'

and this is my controller class ..

 def index 
  @amitian = Amitian.where(institute: current_amitian.institute) if amitian_signed_in?
  @confessions = Confession.where(amitian_id:    @amitian.ids).order('created_at DESC') if amitian_signed_in?
  @anonymous = Amitian.where(email: '[email protected]')
  @anonymous.each do |a|
  @debug = a
if params[:postid] == 'Anonymous'
  @confession = a.confessions.build
else
  @confession = current_amitian.confessions.build 
 end
end
end

my if statement is never true ... why ? A clear f.select statement from above is this =

f.select(:postid,options_for_select('yourname','Anonymous')

so whenever user select anonymous if statement should return true

1
Why do you check params[:postid] in index action? It should be somewhere in create action.mikdiet
thanx alot.. I put that in create method and now its working :) you can post this in as answers I will rate you up .. thanxAlaap Dhall
ok @Alaap, see below.mikdiet

1 Answers

0
votes

You need to check params[:postid] in create action, not in index.