Create and error_messages

No, it shouldn't have anything to do with the RESTful-ness of you application.

--wpd

Patrick Doyle wrote:

Pål Bergström wrote: [...]

  def create     @customer = Customer.new     if @customer.save       flash[:notice] = "Nytt konto skapat"       redirect_to :controller => 'basket'     end

  end

And this in model

validates_presence_of :first_name, :email

I can't get it right. I now get "Missing template customer/create.erb in view path app/views" when trying to save without :first_name

Of course. Your controller code is incorrect. Note that, in the create action, the redirect is only called if @customer.save is true. If validations fail, @customer.save is false, so Rails will try to render the view of the same name as the action ( create.html.erb ). That doesn't exist, so you get an error.

I highly recommend using make_resourceful for your controllers. It will make problems like this easier to avoid.

Best,

Marnen Laibow-Koser wrote:

Pål Bergström wrote:

I highly recommend using make_resourceful for your controllers. It will make problems like this easier to avoid.

What does make_resourceful mean?

Type it into Google. You'll be amazed how good their answer is.

I'll save you the trouble. Here's the project page: http://github.com/hcatlin/make_resourceful

Good luck.

Pål Bergström wrote:

Pål Bergström wrote:

Does it matter, for the error_message_for to be displayed, if I use form_tag or form_for?

You're completely ignoring the advice that Marnen and Patrick gave. Your Create controller method is incorrect. You're not handling the case when the save method fails (due to validation errors). Re-read what Marnen posted about what happens when @customer.save returns false, and compare your create method with Patrick's...