[Rails] Adding validation to ToDo List tutorial

Boon Hoo Thee theebh at gmail.com
Fri Jan 7 15:25:36 GMT 2005


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:)


More information about the Rails mailing list