All pastes #28867 Raw Edit

Someone

public text v1 · immutable
#28867 ·published 2005-11-16 03:24 UTC
rendered paste body
#------ controller

def edit
        @item = Category.find(@params["id"])
        @categories = Category.find_all
    end

    def save
        item = Category.find(@params["id"])
        item.name = @params["name"]
        if item.save
            redirect_to(:action => "list")
        else
            render_text "Couldn't update item"
        end
    end


#--------- view

<html>
<head>
<title>Edit</title>
</head>

<body>
<h1>Edit</h1>

<form action="save" method="post">
    <%= text_field("item", "name") %>
    <input type="submit" value="Save">
</form>
</body>
</html>