I have totally nine buttons in rails. I have input the data into the database by manually typing the @button_1.save function.
My question is:
How can i have the @button_i.save function in rails? I have finished the things in the for loop, what is left is the button save functions.
Many thanks!
button_number = params[:button_number]
for i in (1..button_number)
instance_variable_set("@button#{i}",
Button.new(:title => params["button_title_#{i}".to_sym],
:order => i,
:icon_url => params["button_icon_#{i}".to_sym],
:navigation_id => @navigation.id,
:next_navigation => params["selected_navigation_#{i}".to_sym].to_i,
:next_page => params["selected_page_#{i}".to_sym].to_i))
instance_variable_set("@button#{i}")
end
@button1.save
@button2.save
@button3.save
@button4.save
@button5.save
@button6.save