I have a rails app, in which I want to add buttons dynamically based on my label text in the database.I have a questionnaire schema and it contains label column with various kind of label i.e, PERSONAL STYLE
,STYLING
,WARDROBE
. My UI should automatically add buttons for each label column value i.e. if it contains 3 label in label column then it should add dynamically 3 buttons with PERSONAL STYLE
,STYLING
,WARDROBE
written on it. And on clicking those button , these label specific question must show in UI.
Here is the image for the UI User Interface(UI) for above
My schema is like this with 3 columns. Questionnaire Model which has questionnaire table with these schema
id , label , question
When i click on STYLING
button, STYLING
labeled questions from database should show in UI.
How to achieve that. Currently I am able to load all questions from database.But I have to now show label specific questions on the UI on clicking the label buttons.
here my html.erb code
<% @questionnaire.each do |question| %>
<label> <%= question.label %></label>
<h2> <%= question.text %></h2>
<% end %>
code in controller
@questionnaire = Questionnaire.all
Every suggestions would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire