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

Using :scoped with :history causes Unknown column '<table_name>.scope' when regenerating slug #588

Closed

Conversation

nneufeld
Copy link
Contributor

If I have a model like this:

class Restaurant < ActiveRecord::Base
  extend FriendlyId
  belongs_to :city
  friendly_id :name, :use => [:scoped, :history], :scope => :city
end

The following will result in an ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'restaurants.scope' exception:

restaurant = Restaurant.new
restaurant.city = City.new
restaurant.name = "Joe's Diner"
restaurant.save

restaurant.title = "Bob's Diner"
restaurant.slug = nil
restaurant.save # throws exception(Unknown column 'restaurants.scope' )

This pull request fixes the offending where condition to use friendly_id_slugs.scope

…he History module.

This prevents an ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column '<table_name>.scope' exception
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling f42655a on nneufeld:history_scoped_unknown_column_fix into 97ed06e on norman:master.

@mynock
Copy link

mynock commented Aug 1, 2014

What's the status of this? I also ran into this problem and am currently referencing nneufeld's fork in my Gemfile but would like to switch back to referencing the main repo as soon as possible.

Thanks!

@richardvenneman
Copy link

@mynock I'm currently on friendly_id 5.0.4 via Rubygems and just ran into this issue.

@norman
Copy link
Owner

norman commented Dec 16, 2014

Sorry for the very long response time. This is now merged, I'll push a new version soon.

@norman norman closed this Dec 16, 2014
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

Successfully merging this pull request may close these issues.

5 participants