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

Scope doesn't update when underlying record is changed #16

Closed
nateabbott opened this issue Oct 27, 2009 · 13 comments
Closed

Scope doesn't update when underlying record is changed #16

nateabbott opened this issue Oct 27, 2009 · 13 comments

Comments

@nateabbott
Copy link

Sorry for another issue...

When you have a scoped slug, and the name of the scope changes, the slugs are not updated. i.e. I have users and posts, and there's the option :scope => :user. When I change the friendly_id of the user (which is name), the scope of the posts is not updated, and therefore they cannot be found by the find_one method (which is looking for an item with the new scope)

Let me know if you need a more concrete example. Thanks for the help with this awesome gem!

@norman
Copy link
Owner

norman commented Oct 27, 2009

Thanks, I think your explanation is actually crystal clear. I'll work on a patch for that, but it will likely not be ready today. Probably Thursday or Friday. I have a few other bugs related to scopes to work on, as well as a contributed patch pending, so I'll be doing a small overhaul of the scope features. In the mean time I'd suggest not using cached slugs if this is causing problems for your application, and count on being able to turn them back on by early next week at latest.

@nateabbott
Copy link
Author

no problem -- thanks again for your work on this!

@Exide
Copy link

Exide commented Jan 16, 2010

Removing cached slugs isn't a viable workaround as the scope is still not updated in the slugs table.

@mrrooijen
Copy link

I believe I am experiencing the same issue. I have an application where I have:
Art {nested in} Albums {nested_in} Users. When I update the album_id of my Art model. it will be placed under a different album and will not be accessible through the browser as it will raise the following exception: Cannot find Art with id = "something" and scope = "old album scope". (or something along those lines).

Is this the issue that is being discussed here?

Thanks!

@norman
Copy link
Owner

norman commented Jan 16, 2010

@meskyanichi yes, that sounds like it's the same issue.

I have a received a pull request for a patch which fixes this issue. I'm currently on vacation and will be back home on Tuesday; I'll apply the patch then. In the mean time, you can check out this fork and see if it works for you.

@mrrooijen
Copy link

Hi Norman. Thanks for the reply.
I installed the fork as a plugin, and clone'd it and built a gem and installed that, but both didn't solve the issue. The slug remained unchanged.

Also, after installing the fork gem I receive this error:
undefined method `friendly_id_options' for #Class:0x105115548

Which I noticed was added in the fork. But apparently it could not find it or something.

Anyway no rush or anything, just pointing it out.
Enjoy your vacation, have a good one! ;)

And thanks for building such a sweet gem, it's a great solution and I started using it on every project! This just happens to be the first one I'm scoping with. :)

@norman
Copy link
Owner

norman commented Jan 19, 2010

Updating models used as scope now updates scoped slugs. Closed by 635cc0c.

@mrrooijen
Copy link

Thanks a bunch! I will try it out soon and let you know!

@norman
Copy link
Owner

norman commented Jan 19, 2010

Ah, I didn't realize Github parses the commit messages to automatically close issues now. I had actually intended to leave this open until I pull in @amiablecoder's changes to the master branch. Right now edge and master are significantly different; it was much easier to fix in edge so that's already done. You may wish to give the edge branch a try; all tests pass and I won't be making any more major changes before releasing 2.3.0, though of course there may be bugs. It's a pretty significant refactor.

@amiablecoder the only major issue I've seen so far with the fork is that it doesn't work when the model used as the scope uses slugs, I think it should work with both slugged and non-slugged.

@mrrooijen
Copy link

@amiablecoder Hi, It seems that you've resolved my problem! When I update my top-level association. All children beneath that, and all children beneath these children will get their scopes updated as needed. Thanks a lot for this fix!

saizai pushed a commit to saizai/friendly_id that referenced this issue Jan 23, 2014
This issue was closed.
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

4 participants