rails routing with just the id in the url and form edit -
my application has article
model , url articles this
www.mysite.com/21 www.mysite.com/22
in routes.rb
have set
map.article '/:id', :controller => 'articles', :action => 'show'
everything works fine.
while editing article, form doesn't updated form action pointed article path
for example, form generated
<form action="/48" class="edit_article" enctype="multipart/form-data" id="edit_article_48" method="post"> . . . </form>
when submit form, goes article show page.
this _form.html.erb partial
<% form_for @article, :html => { :multipart => true } |f| %> . . . <% end %>
has faced kind of problem before? please help
thanks
you should configure routing requests retrive article while put/post requests invoke other actions update/create articles.
refer rails guide routing more information. btw assuming using rails 2.
i recommend use restful routing. like:
map.root :controller => 'articles' map.resources :article
then:
get www.mysite.com/21 go show put www.mysite.com/21 go update post www.mysite.com/21 go create
..etc
Comments
Post a Comment