Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined method `find_one_without_friendly_id' #485

Closed
flexid opened this issue Nov 15, 2013 · 15 comments
Closed

Undefined method `find_one_without_friendly_id' #485

flexid opened this issue Nov 15, 2013 · 15 comments

Comments

@flexid
Copy link

flexid commented Nov 15, 2013

First of all, thank you for this awesome gem! I'm very much stuck on this thing now:

With globalize 3.0.0 and friendly_id 4.0.10 in Rails 3.2 (using :globalize and :history together) I get the following error when I want to show a translated object:

undefined method `find_one_without_friendly_id' for #<Product::GlobalizeActiveRecordRelation:0x007fcdc3d31f10>

Also, it's not querying any translation tables! It looks for the translated slug in the default table.

Here's the full trace: http://dpaste.com/1464015/

And oh, I define my translations and slugs like this:

  extend FriendlyId
  translates :name, :subname, :description, :slug, :tagline, :advice, :details, :benefits
  friendly_id :name, :use => [:globalize, :history, :slugged]

If I do it like this:

  translates :name, :subname, :description, :slug, :tagline, :advice, :details, :benefits
  extend FriendlyId
  friendly_id :name, :use => [:globalize, :history, :slugged]

I get a stack level too deep SystemStackError...

Thanks.

PS. Nothing on StackOverflow...

@humandoing
Copy link

I actually just stumbled across this same issue today. I am not trying to globalize the URI slug, but even just doing an:

SomeObject.find( "1" )

explodes with something like:

undefined method `find_one_without_friendly_id' for #<Group::GlobalizeActiveRecordRelation:0x007f94621d8b40>

I'm wondering if the issue should actually be reported to the Globalize team. Without looking at the code, but looking at the error message my gut tells me that something they are patching into ActiveRecord is clobbering find_one_without_friendly_id

I did notice that there was the friendly_id-globalize gem (by @parndt) but that has a dev dependency of FriendlyID > 5.0 which doesn't do any good for the folks running Rails 3 (given that FriendlyID 5.0 is for Rails 4 and up).

Thoughts?

@parndt
Copy link
Collaborator

parndt commented Nov 19, 2013

cc @shioyama

@shioyama
Copy link
Contributor

Aak. Yes that is definitely a globalize issue. Could you post this to the globalize github issue page and reference this? We'll follow up there.

@shioyama
Copy link
Contributor

I just realized I fixed this in 3.0.1, see globalize/globalize@862cfd4. Can you try updating?

@humandoing
Copy link

Hi Chris,

I am definitely using 3.0.1

vagrant@chimp /opt/chimp % bundle | grep globalize
Using globalize (3.0.1)

On Nov 19, 2013, at 4:36 PM, Chris Salzberg [email protected] wrote:

I just realized I fixed this in 3.0.1, see globalize/globalize@862cfd4. Can you try updating?


Reply to this email directly or view it on GitHub.

@shioyama
Copy link
Contributor

Hmm.. thanks, will investigate then.

@humandoing
Copy link

@shioyama

I've been looking at and trying to debug this a little bit more (causing me a lot of grief).

For reference, my model is Group.

# works with globalize
Group.find("slug-name") 

# works with globalize
Group.find( 1 ) 

# should end up reverting to search using 1 for ID, but bombs and dies with exception I previously mentioned
Group.find( "1" ) 

(sorry for all the comments - just trying to figure out how to get this working - and hoping I can be helpful in the process)

@shioyama
Copy link
Contributor

@humandoing

Thanks for your investigation. I pretty much know what the issue is. The problem is that I originally read the FriendlyId comments here and misunderstood the intention of the pattern that @norman setup. I just need to change how globalize overrides ActiveRecord::Base#relation so that both gems can work together.

The first step will be to cherry-pick globalize/globalize@32af839 from the globalize master (AR4) branch into 3-0-stable, so that I can include the necessary methods as a module rather than create a new class that inherits from ActiveRecord::Relation, which seems to be the source of the conflict with FriendlyId. Just give me a day or two.

@humandoing
Copy link

Thanks @shioyama - very much appreciated.

@flexid
Copy link
Author

flexid commented Nov 20, 2013

Appreciated indeed, thanks everyone!

@shioyama
Copy link
Contributor

@humandoing @flexid Can you try the branch that I just created?

gem 'globalize', github: 'globalize/globalize', branch: 'issue_306_friendly_id_relation_conflict'

@flexid
Copy link
Author

flexid commented Nov 21, 2013

@shioyama At first sight this is working fluently dude. Thank you so much for the quick response!

@shioyama
Copy link
Contributor

@flexid Thanks for checking. I've merged this into globalize 3-0-stable and if there are no issues will release as v3.0.2 in the next few days.

@humandoing
Copy link

Heya @shioyama - took me a little longer but I've pulled the branch and tested my use case above and everything seems to be working. Thanks very much!

@norman
Copy link
Owner

norman commented Dec 10, 2013

Closing this in favor of the issue over at Globalize.

@norman norman closed this as completed Dec 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants