I am trying to make a form where a user can wither post normally with their username like this - > normal
=form_for @confession , html: {multipart: true} do |f|
=f.label :Confess
=f.text_area :confession , require: true
=f.file_field :confessionimage
=f.select (:id,options_for_select(ID))
=f.submit 'Confess'
or Anonymously where their Names will be hidden and no one will know that who posted this post .. for this what I thought was I will make a user named anonymous in database and if a user select anonymous in select_form while posting they will post as an anonymous user.
for this in my controller I want something like this and main point that I can't understand is how can the controller know what user has selected ?
this is my controller
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?
@confession = current_amitian.confessions.build
@anonymous = Amitian.where(email: anonymous@anonymous.com)
# (if anonymous selected )
do @anonymous.confessions.build
end
can anyone plz help me how can I achieve this ? Plz hhelp m stuck at this part
Aucun commentaire:
Enregistrer un commentaire