I've found a few Stack Overflow articles saying to specify URLs, while 
others say it should work.

If someone can just tell me that it won't ever work without manually 
specifying the URLs, I'd be happy. Just looking for a final answer.

On Wednesday, April 24, 2013 5:00:50 PM UTC+10, Ben Taylor wrote:
>
> I don't have a complete understanding here, but from what I'm seeing I'm 
> assuming that the way the URL is determined from a form_for takes into 
> account the objects type. So you have:
>
> [:reconciliation, Reconciliation::Charge, Reconciliation::ChargeRate]
>
> which rails is deciding should make a URL that looks like...
>
> ["reconciliation", "reconciliation_charge", "reconiciliation_charge_rate"]
>
> when what you actually want is
>
> ["reconciliation", "charge", "charge_rate"] 
>
> I've never namespaced my models, so I've never personally come across 
> this. If you are okay with a fix that changes your models, you could remove 
> the namespacing from your models and that would fix it.
>
> Looking at StackOverflow all I can see is a recommendation to specify the 
> URL yourself. 
> http://stackoverflow.com/questions/11713427/form-for-with-module-and-namespace
>
> Does that help?
>
> - Ben
>
> On Wednesday, 24 April 2013 at 3:34 PM, Michael Webb wrote:
>
> Hi all,
>
> I'm building a fairly large Rails app for my current client and am doing a 
> bit of a restructure of the database after a manic few months getting 
> version one up and running.
>
> I've tried to group tables into namespaces based on functionality and am 
> having some serious difficulty getting form_for to work when it is 
> operating on nested resources within a namespace.
>
> From routes.rb:
> *...*
> * namespace :reconciliation do*
> * resources :charges do*
> * resources :charge_rates*
> *  end
> *
> * end*
> *...*
> *
> *
> From the relevant _form.html:
> *= form_for [:reconciliation, @charge, @charge_rate], :html => 
> {:multipart => true, :class => "edit_form"} do |f|*
> ...
>
> The line above raises: *undefined method 
> `reconciliation_reconciliation_charge_reconciliation_charge_rates_path' for 
> #<#<Class:0x3758100>:0x3778080>* in polymorphic_url.
> *
> *
> I have verified that both @charge and @charge_rate are not null and are of 
> the appropriate type (Reconciliation::Charge and 
> Reconciliation::ChargeRate).
>
> rake routes shows that the reconciliation_charge_charge_rates_path exists.
>
> According to every article I could find on Stack Overflow, my _form.html 
> code *should* work, what am I doing wrong?
>
> Thanks,
>
> Mike
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]<javascript:>
> .
> Visit this group at http://groups.google.com/group/rails-oceania?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>  
>  
>  

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rails-oceania?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to