Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## controller:
- def create
- @service = Service.new(params[:service])
- @notigroups = Notificationgroupdetail.find(:all)
- @notigroups << ["None", "0"]
- @hosts = Host.find(:all).collect {|p| [p.name, p.id] }
- @hosts << ["None", "0"]
- if @service.save
- flash[:notice] = "Service has been added!"
- redirect_to :action => "index"
- else
- flash[:error] = "Could not add service. Check error messages."
- render :action => "new"
- end
- end
- ## view:
- <div id="service-new">
- <% form_for :service, :url => { :action => "create" } do |f| %>
- <fieldset>
- <legend>Main</legend>
- <dl>
- <dt>Name</dt>
- <dd><%= f.text_field :name %> <%= error_message_on(:service, :name) %></dd>
- <dt>Host</dt>
- <dd><%= f.text_field :host %> <%= error_message_on(:service, :host) %></dd>
- <dt>Port</dt>
- <dd><%= f.text_field :port %> <%= error_message_on(:service, :port) %></dd>
- <dt>Protocol check</dt>
- <dd><%= f.select :type, getServiceTypes.sort %> <%= error_message_on(:service, :type) %></dd>
- <dt>Timeout (seconds)</dt>
- <dd><%= f.text_field :timeout, :value => "5" %> <%= error_message_on(:service, :timeout) %></dd>
- <dt>Max. response time (ms)</dt>
- <dd><%= f.text_field :maxres, :value => "250" %> <%= error_message_on(:service, :maxres) %></dd>
- <dt>Notification group</dt>
- <dd>
- <%= f.select :warninggroup, @notigroups %>
- <%= error_message_on(:service, :warninggroup) %>
- </dd>
- <dt>Link to host</dt>
- <dd>
- <%= f.select :linkedhost, @hosts %>
- <%= error_message_on(:service, :linkedhost) %>
- </dd>
- </dl>
- </fieldset>
- <fieldset>
- <legend>Control</legend>
- <%= submit_tag %>
- </fieldset>
- <% end %>
- </div>
- ## html output of the field that is complained about:
- <dd><div class="fieldWithErrors"><select id="service_type" name="service[type]"><option value="ftp">FTP</option>
- <option value="http">HTTP</option>
- <option value="imap">IMAP</option>
- <option value="none">None</option>
- <option value="pop3">POP3</option>
- <option value="smtp">SMTP</option>
- <option value="ssh">SSH</option></select></div> <div class="formError">can't be blank</div></dd>
Add Comment
Please, Sign In to add comment