I'm seeing this in a project, too (Ruby 1.9.3, Hobo 2.1, Rails 4.0.5).
polymorphic_url has failed with NoMethodError: undefined method
`new_product_path' for #<#<Class:0x007fd4c516cf00>:0x007fd4c50f7840>
I'm not sure what value that "for #<#<Class:...." has when trying to solve
the problem. If that value can't be sensibly used to track down the
problem, just don't drop it in the log :)
Looks, to me, that the most important clue is the line that follows the
list (I have 31 of these messages, one after the other - it's a paged
table). The line after them says:
Rendered controller: products; dryml-tag: index-page (9893.2ms)
That clues me in to where to look. That line appears once, versus 31 errors
with two pieces of data (new_product_path' and 'edit_product_path', between
them. There should be more prominence to the Rendered Controller, and less
to repetitions of a message that adds little... but I recognise that's not
always easy to organise when spitting out error messages and warnings.
So, yeah, if this can be improved, I'd focus on a diagnostic that tells
users what they should be looking at. Not an anonymous class, IOW.
Here's what I think is the Big Thing in this issue:
In my case... I've marked that "product" is read_only in my controllers. I
don't want an "Edit" or a "New" path, anywhere (for this project, products
are taken from another resource that is not humanly editable - I need the
products. I can't have them modified).
Perhaps the real problem is that the controller instruction:
auto_actions :read_only
Needs to influence the generation of the views, not just the navigation? Or
perhaps what I'm missing is the right way to express to Hobo that these
paths for writing and creating a resource, should never be considered for
use in the interface for this resource?
Cheers, JeremyC.
On Wednesday, 7 May 2014 19:49:34 UTC+1, Ignacio Huerta wrote:
>
> Hi Lea,
>
> Good news, I have reproduced your issue :). I have set up an app with
> the same models and controllers, and when navigating to
> "/admin/registrations/1", I see in the log similar errors:
>
> polymorphic_url has failed with NoMethodError: undefined method
> `account_admin_user_path' for
> #<#<Class:0x00000004a0bb18>:0x00000001cd65f8>
>
> polymorphic_url has failed with NoMethodError: undefined method
> `admin_accommodation_path' for
> #<#<Class:0x00000004a0bb18>:0x00000001cd65f8>
>
> And if you look into the screenshot, you can see that the account link
> could not be found inside the admin controller, and the same thing with
> the accommodation link. These are the corresponding warnings in the log:
>
> I added these "warnings" in this commit:
>
> https://github.com/Hobo/hobo/commit/be9fb7d7e9113e3c5a354104fbbef4a3a3e1e26d.
>
> My intention was to help users debug when a form was not rendered and
> failed silently. Maybe the messages should be written in a more
> descriptive way. Any suggestion?
>
>
> Workaround for now: find the links that Hobo is not capable of routing
> to and replace them manually in Dryml with the correct route. Please ask
> if you need help with this.
>
> Solution for the future: make Hobo smarter when using subsites, so it's
> really capable of finding the correct route. I'll open a Github issue.
>
> Warm regards,
> Ignacio
>
> El 05/05/14 22:10, Lea Viljanen escribió:
> > I have some old Hobo/Rails 3 code I successfully ported to new
> Hobo/Rails 4.
> > Except for some polymorphic route issues, which are kind of a new
> > thing for Rails 4.
> >
> > I have this piece of code:
> >
> > class Registration
> > belongs_to :accommodation, :accessible => true
> >
> > class Accommodation
> > fields do
> > price :integer
> > end
> >
> > And now I have a controller where I have a method:
> >
> > def list_indoors
> > ....
> > @registrations = Registration.joins(:accommodation).where('price >
> 0' ).load
> >
> > hobo_show @registrations, :order => "created_at DESC"
> >
> > end
> >
> > Which, when run, gives me an error:
> >
> > polymorphic_url has failed with NoMethodError: undefined method
> > `accommodation_path' for #<#<Class:0xb438c390>:0xb4397ba0>
> >
> > I have some other code like this as well, and the issue plagues all my
> > methods, where I'm going through a joins directive in selecting the
> > displayed data. If I have a simple .where filter, no problems
> > whatsoever. This may or may not be related.
> >
> > Second thing to note, the controller for the affected model is in an
> > admin subsite, because that's where I create and edit the model data
> > and thus the
> > resource :accommodation
> > is also in the subsite section of hobo_routes.rb
> >
> > There is no resource directive in the main website routes for the
> > Accommodation model because I don't need accommodation data to be HTTP
> > accessible from main web site. If I add the resource :accommodation to
> > routes.rb for the main website section, I get rid of the undefined
> > method error but I start getting errors about the "missing"
> > AccommodationsController. But I don't need that.
> >
> > The code actually works, with errors and all, but I want to know
> > what's wrong and how I get rid of the error.
> >
> > Do I need to do something specific with Hobo routes when upgrading?
> >
>
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers.
For more options, visit https://groups.google.com/d/optout.