# Problem Routing E

**URL:** <https://www.ruby-forum.com/t/problem-routing-e/145856>\
**Category:** Rails\
**Created:** [August 14, 2008, 4:16pm UTC](https://www.ruby-forum.com/t/problem-routing-e/145856 "2008-08-14T16:16:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikej](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a9a28c/32.png) [@mikej](https://www.ruby-forum.com/u/mikej)\
**Post date:** [August 14, 2008, 4:16pm UTC](https://www.ruby-forum.com/t/problem-routing-e/145856/1 "2008-08-14T16:16:01Z")

</div>

I have a controller to edit titles and text\_html for a given client.

route to page:

mynamespace/mycontroller/client-permalink/edit

def edit

```
@client = Client.find_by_permalink(params[:id])

if Title.exists?(['client_id = ? AND page_id = 10', @client.id])
  @title=Title.find(:last,:conditions => ['client_id = ? AND

```

page\_id = 10’, @client.id])  
else  
@title=Title.new  
end

```
if TextHtml.exists?(['client_id = ? AND page_id = 10',

```

@client.id])  
@text\_html=TextHtml.find(:last,:conditions =\> [‘client\_id = ?  
AND page\_id = 10’, @client.id])  
else  
@text\_html=TextHtml.new  
end  
end

edit.html.erb:

\<% form\_for :client\_title\_text, :url =\> {:action =\> :update, :id =\>  
@client.permalink} do |form| %\>

```
 <% fields_for :title do |t| %>
 Title: <%= t.text_field :title %><br/>
 <% end %>

 <% fields_for :text_html do |th| %>
 Title: <%= th.text_field :text_html %><br/>
 <% end %>

 <%= submit_tag 'Save',:class => "submit" %>

```

\<% end %\>

My problem is that when the form submits, it looks for the client-  
permalink action instead of the update action.

Relevant route:

map.namespace :mynamespace do | mynamespace |  
mynamespace.resources :mycontroller  
end

Models:  
Client:  
has\_many :titles, :dependent =\> :destroy  
has\_many :text\_htmls, :dependent =\> :destroy  
Title:  
belongs\_to :page  
belongs\_to :client  
TextHtml

belongs\_to :page  
belongs\_to :client

Any ideas gratefully received,

Many thanks,

Mike
