It successfully creates a server but the problem is it doesn't proceed to the else statement if it doesn't save.
servers_controller.rb
def create
@server = Server.new(server_params)
if @server.save
flash[:sucess] = "Server created successfully!"
redirect_to servers_path
else
render 'new'
end
end
_form.html.erb
<div class="jumbotron">
<%= bootstrap_form_for @server do |f| %>
<%= f.text_field :name, required: true %>
<%= f.text_field :ip_address, label: "Ip Address", required: true %>
<%= f.select :database_name, options_for_select(@db_names), label: "Current Databases:" %>
<%= f.submit %>
<% end %>
</div>
Aucun commentaire:
Enregistrer un commentaire