dimanche 24 juillet 2016

Ruby on rails create a new variable to make an each

i'm new into ruby on rails and i want to assign a variable to make an each like this

<% 3.times do |calendar| %>
 <% test = @lessons_calendar %>
   <% test.each do |lesson| %>
     display html here
   <% end %>
<% end %>

The thing is that in my controller i have assigned 3 variables like this @lessons_1 @lessons_2 and @lessons_3 but when i run the code it says undefined method `each' for nil:NilClass, how can i join the number created by calendar to the new variable ? Thanks

Aucun commentaire:

Enregistrer un commentaire