Hi there
Implementing my first “update” procedure worked fine.
I took this as a template for a “create” procedure, but that does not
work as expected: when I enter invalid data, the validation stops me
from saving the data, that’s working, but all fields are cleared!
Furthermore, also the data is not saved, no error message is dislayed.
Advice is more then welcome!
Controller Code:
def create_client
case request.method
when :get
@client = Client.new
when :post
client = Client.new(params[:client])
if client.save true
flash[:notice] = “Client successfully added”
redirect_to({:controller => ‘client’, :action => ‘overview’},
true)
else
flash[:errobj] = ‘client’
end
end
end
Layout Code
<% if flash[:errobj] -%>
<%= error_messages_for flash[:errobj] -%>
<% end %>