[Rails] Adding validation to ToDo List tutorial

Tanner Burson tanner.burson at gmail.com
Fri Jan 7 15:33:36 GMT 2005


On Fri, 7 Jan 2005 23:25:36 +0800, Boon Hoo Thee <theebh at gmail.com> wrote:
> Finally found the answer...
> 
> After diggin the API, I realise that render_action actually load the
> template with the action name, but does not execute the method. so
> what I should have done is just call the 'list' method one more time:
> 
>     def add_item
>         @item = Todo.new
>         @item.attributes = @params["new_item"]
>         if @item.save
>             redirect_to(:action => "list")
>         else
>             list  # <- call list method to load the @done and
> @not_done variables
>             render_action "list"
>         end
>     end
> 
> Is this the correct way? Rails is fun:)

I believe the correct method would be to use a redirect so that it
lets rails handle calling the new controller method.  But your way
should work as well.


More information about the Rails mailing list