Rails Nested Route For Singular Resource
routes, ruby-on-rails
Solution
I think what you want to do is
<% form_for [:account, @feed] do |f| %>
form_for will then look to use the account_feeds_path with POST when @feed is a new record and account_feed_path(@feed) with PUT when @feed is not a new record.
Problem
I have a nested route on a singular resource ``` map.resource :account, :controller => "users" do |page| page.resources :feeds end ``` I'm trying to make a form to add a feed. I start with this... ``` <% form_for @feed do |f| %> undefined method `feeds_path' for #<ActionView::Base:0x2123174> ``` So I try ``` <% form_for [current_user,@feed] do |f| %> undefined method `user_feeds_path' for #<ActionView::Base:0x20b3e00> ``` I guess that is due to renaming it from "users" to "account"? So I tried ``` <% form_for account_feeds_path(@feed) do |f| %> `@/account/feeds.%23%3Cfeed:0x22ea5c0%3E' is not allowed as an instance variable name ``` Not sure what that error means. So I've resorted to using doing this which works: ``` <% form_for @feed, :url=>{:action=>:create} do |f| %> ``` Is that really the best way? In other words, is there no way to use named routes in this situation?