# Edit not working with named routes

**URL:** <https://www.ruby-forum.com/t/edit-not-working-with-named-routes/110913>\
**Category:** Rails\
**Created:** [August 1, 2007, 12:37am UTC](https://www.ruby-forum.com/t/edit-not-working-with-named-routes/110913 "2007-08-01T00:37:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gareth\_Townsend](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4bbf92/32.png) [@Gareth\_Townsend](https://www.ruby-forum.com/u/Gareth_Townsend)\
**Post date:** [August 1, 2007, 12:37am UTC](https://www.ruby-forum.com/t/edit-not-working-with-named-routes/110913/1 "2007-08-01T00:37:52Z")

</div>

HELP! I’m a relatively new rails user and I’m stuck. I’m trying to  
build a relatively simple blog and I decided that I liked the way  
named routes look in the code. So I added

map.resources :posts

to my routes.db file. I then went through and updated my controller to  
take advantage of the named routes that were generated. I also updated  
all of my views and everything was working nicely. Except when I try  
to edit an existing post. For some reason it just doesn’t want to do  
anything. Below are the relevant (I think) parts of the  
PostsController:

class PostsController \< ApplicationController  
layout “blog”  
before\_filter :login\_required, :except =\> [:index, :show]  
before\_filter :find\_post, :except =\> [:index, :new, :create]

def edit  
end

def update  
if @post.update\_attributes(params[:post])  
flash[:notice] = “Post Updated”  
redirect\_to post\_url(@post)  
else  
render edit\_post\_url  
end  
end

protected

def find\_post  
@post = Post.find(params[:id])  
end  
end

Here is edit.hrtml

# New Post
\<% form\_for(:post, @post, :url =\> post\_url(@post), :html =\> {:method =\> 'put'}) do |f| %\> \<%= render :partial =\> "form", :object =\> f %\> \<% end %\>

And the form partial…

Title  
 \<%= form.text\_field :title %\>

Permalink  
 \<%= form.text\_field :permalink %\>

Abstract  
 \<%= form.text\_area :abstract %\>

Body  
 \<%= form.text\_area :body %\>

\<%= submit\_tag %\>

Have I done something stupid? I get the feeling I probably have and  
it’s making the edits not work.
