I am new to ruby and rails coming from a perl background.
I was hoping someone could help point me to some sample code to
serialize data from a form.
My plan is to write a tiny app to generate Cisco switch configuration
files based on a template.
Below is what I have found so far based on what I could find.
Unfortunately the form does not automagically re-insert the values after
they are saved. I noticed other people commenting about the same
feature. Is there a better way of doing this?
How would I create an array of vlans under the variable configuration
using the form?
I am planning on adding an “add vlan” button which reloads the same
form, but I am not sure of the syntax.
Any pointers would be helpful.
Thanks in advance,
=== switch.rb ===
class Switch < ActiveRecord::Base
=== _form.html.erb ===
<%= form_for(@switch) do |f| %>
<% if @switch.errors.any? %>
<%= pluralize(@switch.errors.count, “error”) %> prohibited
this switch from being saved:
<ul> <% @switch.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div>
<% end %>
<%= f.text_field :name %>
<%= f.fields_for :configuration do |c| %> <%= c.text_field :snmpCommunity %> <%= c.text_field :ipAddress %> <% end %>