Giter VIP home page Giter VIP logo

acts_as_favoritor's Introduction

acts_as_favoritor

acts_as_favoritor is a Rubygem to allow any ActiveRecord model to associate any other model including the option for multiple relationships per association with scopes.

You are able to differentiate followers, favorites, watchers, votes and whatever else you can imagine through a single relationship. This is accomplished by a double polymorphic relationship on the Favorite model. There is also built in support for blocking/un-blocking favorite records as well as caching.

This Medium article gives a good introduction to this gem.

Installation

You can add acts_as_favoritor to your Gemfile with:

gem 'acts_as_favoritor'

And then run:

$ bundle install

Or install it yourself as:

$ gem install acts_as_favoritor

If you always want to be up to date fetch the latest from GitHub in your Gemfile:

gem 'acts_as_favoritor', github: 'jonhue/acts_as_favoritor'

Now run the generator:

$ rails g acts_as_favoritor

To wrap things up, migrate the changes into your database:

$ rails db:migrate

Usage

Setup

Add acts_as_favoritable to the models you want to be able to get favorited:

class User < ActiveRecord::Base
  acts_as_favoritable
end

class Book < ActiveRecord::Base
  acts_as_favoritable
end

Specify which models can favorite other models by adding acts_as_favoritor:

class User < ActiveRecord::Base
  acts_as_favoritor
end

acts_as_favoritor methods

book = Book.find(1)
user = User.find(1)

# `user` favorites `book`.
user.favorite(book)

# `user` removes `book` from favorites.
user.unfavorite(book)

# Whether `user` has marked `book` as his favorite.
user.favorited?(book)

# Returns an Active Record relation of `user`'s `Favorite` records that have not been blocked.
user.all_favorites

# Returns an array of all unblocked favorited objects of `user`. This can be a collection of different object types, e.g.: `User`, `Book`.
user.all_favorited

# Returns an Active Record relation of `Favorite` records where the `favoritable_type` is `Book`.
user.favorites_by_type('Book')

# Returns an Active Record relation of all favorited objects of `user` where `favoritable_type` is 'Book'.
user.favorited_by_type('Book')

# Returns the exact same as `user.favorited_by_type('User')`.
user.favorited_users

# Whether `user` has been blocked by `book`.
user.blocked_by?(book)

# Returns an array of all favoritables that blocked `user`.
user.blocked_by

acts_as_favoritable methods

# Returns all favoritors of a model that `acts_as_favoritable`
book.favoritors

# Returns an Active Record relation of records with type `User` following `book`.
book.favoritors_by_type('User')

# Returns the exact same as `book.favoritors_by_type('User')`.
book.user_favoritors

# Whether `book` has been favorited by `user`.
book.favorited_by?(user)

# Block a favoritor
book.block(user)

# Unblock a favoritor
book.unblock(user)

# Whether `book` has blocked `user` as favoritor.
book.blocked?(user)

# Returns an array of all blocked favoritors.
book.blocked

Favorite model

# Returns an Active Record relation of all `Favorite` records where `blocked` is `false`.
Favorite.unblocked

# Returns an Active Record relation of all `Favorite` records where `blocked` is `true`.
Favorite.blocked

# Returns an Active Record relation of all favorites of `user`, including those who were blocked.
Favorite.for_favoritor(user)

# Returns an Active Record relation of all favoritors of `book`, including those who were blocked.
Favorite.for_favoritable(book)

Scopes

Using scopes with acts_as_favoritor enables you to Follow, Watch, Favorite, [...] between any of your models. This way you can separate distinct functionalities in your app between user states. For example: A user sees all his favorited books in a dashboard ('favorite'), but he only receives notifications for those, he is watching ('watch'). Just like YouTube or GitHub do it. Options are endless. You could also integrate a voting / star system similar to YouTube or GitHub

By default all of your favorites are scoped to 'favorite'.

You can create new scopes on the fly. Every single method takes scope/scopes as an option which expects a symbol or an array of symbols containing your scopes.

So lets see how this works:

user.favorite(book, scopes: [:favorite, :watching])
user.unfavorite(book, scope: :watching)
second_user = User.find(2)
user.favorite(second_user, scope: :follow)

That's simple!

When you call a method which returns something while specifying multiple scopes, the method returns the results in a hash with the scopes as keys when scopes are given as an array:

user.favorited?(book, scopes: [:favorite, :watching]) # => { favorite: true, watching: false }
user.favorited?(book, scopes: [:favorite]) # => { favorite: true }
user.favorited?(book, scope: :favorite) # => true

acts_as_favoritor also provides some handy scopes for you to call on the Favorite model:

# Returns all `Favorite` records where `scope` is `my_scope`
Favorite.send("#{my_scope}_list")

## Examples
### Returns all `Favorite` records where `scope` is `favorites`
Favorite.favorite_list
### Returns all `Favorite` records where `scope` is `watching`
Favorite.watching_list

Caching

When you set the option cache in config/initializers/acts_as_favoritor.rb to true, you are able to cache the amount of favorites/favoritables an instance has regarding a scope.

For that you need to add some database columns:

acts_as_favoritor

add_column :users, :favoritor_score, :text
add_column :users, :favoritor_total, :text

acts_as_favoritable

add_column :users, :favoritable_score, :text
add_column :users, :favoritable_total, :text
add_column :books, :favoritable_score, :text
add_column :books, :favoritable_total, :text

Caches are stored as hashes with scopes as keys:

user.favoritor_score # => { favorite: 1 }
user.favoritor_total # => { favorite: 1, watching: 1 }
second_user.favoritable_score # => { follow: 1 }
book.favoritable_score # => { favorite: 1 }

Note: Only scopes who have favorites are included.

acts_as_favoritor makes it even simpler to access cached values:

user.favoritor_favorite_cache # => 1
second_user.favoritable_follow_cache # => 1
book.favoritable_favorite_cache # => 1

Note: These methods are available for every scope you are using.

The total counts all favorites that were recorded, while the score factors in favorites that were removed. In most use cases the score is the most useful.

Configuration

You can configure acts_as_favoritor by passing a block to configure. This can be done in config/initializers/acts_as_favoritor.rb:

ActsAsFavoritor.configure do |config|
  config.default_scope = :follow
end

default_scope Specify your default scope. Takes a string. Defaults to :favorite. Learn more about scopes here.

cache Whether acts_as_favoritor uses caching or not. Takes a boolean. Defaults to false. Learn more about caching here.

Development

To start development you first have to fork this repository and locally clone your fork.

Install the projects dependencies by running:

$ bundle install

Testing

Tests are written with RSpec and can be found in /spec.

To run tests:

$ bundle exec rspec

To run RuboCop:

$ bundle exec rubocop

Contributing

We warmly welcome everyone who is intersted in contributing. Please reference our contributing guidelines and our Code of Conduct.

Releases

Here you can find details on all past releases. Unreleased breaking changes that are on the current main can be found here.

acts_as_favoritor follows Semantic Versioning 2.0 as defined at http://semver.org. Reference our security policy.

Publishing

  1. Review breaking changes and deprecations in CHANGELOG.md.
  2. Change the gem version in lib/acts_as_favoritor/version.rb.
  3. Reset CHANGELOG.md.
  4. Create a pull request to merge the changes into main.
  5. After the pull request was merged, create a new release listing the breaking changes and commits on main since the last release.
  6. The release workflow will publish the gem to RubyGems.

acts_as_favoritor's People

Contributors

7200rpm avatar criccomini avatar dependabot[bot] avatar depfu[bot] avatar djaircarvalho avatar graysonchen avatar jbpfran avatar jonhue avatar kwent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

acts_as_favoritor's Issues

Caching not working correctly

NoMethodError (undefined method '+' for nil:NilClass)

irb(main):040:0> begin
irb(main):041:1> User.first.favorite Product.last
irb(main):042:1> rescue => e
irb(main):043:1> puts e.backtrace
irb(main):044:1> raise e
irb(main):045:1> end
NoMethodError (undefined method `+' for nil:NilClass)
/Users/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/acts_as_favoritor-b84d096e75c6/lib/acts_as_favoritor/favoritor.rb:125:in `favorite'
/Users/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/acts_as_favoritor-b84d096e75c6/lib/acts_as_favoritor/favoritor_lib.rb:50:in `validate_scopes'
/Users/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/acts_as_favoritor-b84d096e75c6/lib/acts_as_favoritor/favoritor.rb:105:in `favorite'

Undefined method '+' for :scope:Symbol

Walkthrough
Awesome gem so far, enjoyed using it to implement a favorite functionality which works great. Right now, I'd like to add a scope for verify functionality. Adding the scope to verify works but when I check if it's been favorited with verify scope or try to remove_favorite with the verify scope, I get the following error:

NoMethodError: undefined method +' for :verify:Symbol`

Any ideas?

I saw #26 and tried to use this gem 'acts_as_favoritor', github: 'jonhue/acts_as_favoritor' in the gemfile instead to get the latest version but niet.

Screenshot
See attached ๐Ÿ‘‡

screenshot 2019-03-08 at 4 40 02 pm

Expected behavior
Expected behaviour was to receive a true or false if user has been verified and to be able to remove verification.

Local env:

  • OS: MacOS Mojave 10.14.3
  • Browser: Chrome
  • Version 72.0.3626.119

undefined method `[]' for nil:NilClass when caching enabled

Describe the bug

First thanks for your OSS contribution !

I'm trying to make it work with cache enabled (cannot repro the bug with cache disabled) (Using upstream version 442e2cd752684f180b712b8abeedaab22ab40e6c)

When doing

current_user.favorite @product

The following exceptions is raised: undefined method [] for nil:NilClass.

acts_as_favoritor-442e2cd75268/lib/acts_as_favoritor/favoritor.rb:122:in `favorite'
acts_as_favoritor-442e2cd75268/lib/acts_as_favoritor/favoritor_lib.rb:50:in `validate_scopes'
acts_as_favoritor-442e2cd75268/lib/acts_as_favoritor/favoritor.rb:102:in `favorite'

This stacktrace is referencing this line: https://github.com/jonhue/acts_as_favoritor/blob/master/lib/acts_as_favoritor/favoritor.rb#L122

Here are my models:

class User < ApplicationRecord
  acts_as_favoritor
end
class Product < ApplicationRecord
  acts_as_favoritable
end

Here is my cache migration:

class AddFavoritesCacheToUserAndProductTable < ActiveRecord::Migration[5.2]
  def change
    add_column :users, :favoritor_score, :text
    add_column :users, :favoritor_total, :text

    add_column :products, :favoritable_score, :text
    add_column :products, :favoritable_total, :text
  end
end

Looks like this favoritor_score is never initialized ?

Regards

Release 4.0.0

Breaking changes:

  • changing how blocking/unblocking works
    • only favoritables can block favoritors now
    • renaming blocks to blocked for favoritables
    • renaming blocks to blocked_by and blocked? to blocked_by? for favoritors
  • renaming remove_favorite to unfavorite
  • removing descending and recent class methods
  • removing the special handling of the :all scope

Release 5.0.0

Breaking changes:

  • Passing an array containing a single scope to a method (e.g. user.favorited?(book, scopes: [:purchase])) now returns a hash as a result (e.g. { purchase: true }). Use user.favorited?(book, scope: :purchase) to receive the same result as in earlier versions.

4c52e71 [#136] Allow either a single scope or multiple scopes to be given (#137)
af354c1 Update rspec-rails to version 3.9.1 (#134)
cc02985 Update rubocop to version 0.80.1 (#132)
811f8b9 Update rubocop to version 0.80.0 (#131)
59ac112 Update rubocop-rspec to version 1.38.1 (#130)
56f1912 Update rubocop-rspec to version 1.38.0 (#129)
288a463 Update nokogiri to version 1.10.8 (#128)
137c981 Update rubocop to version 0.79.0 (#127)
1fe95d2 Update all of rails to version 6.0.2.1 (#125)
f6a0f33 Update rubocop-rspec to version 1.37.1 (#121)
dc05526 Update sqlite3 to version 1.4.2 (#124)
683055a Update rack to version 2.0.8 (#122)
b3d15bb Update rubocop: 0.77.0 โ†’ 0.78.0 (major) (#126)
cdea494 Update all of rails to version 6.0.2 (#120)
b02fc85 Update rubocop-rspec: 1.36.0 โ†’ 1.37.0 (minor) (#117)
1d400f4 Bump puma from 3.12.1 to 3.12.2 in /spec/support/rails_app (#119)
7e83a1d Update rubocop to version 0.77.0 (#118)
53c4c3c Update all of rails: 6.0.0 โ†’ 6.0.1 (patch) (#115)
5fb9b55 Bump loofah from 2.2.3 to 2.3.1 in /spec/support/rails_app (#116)
cb8014a Update rubocop to version 0.76.0 (#114)
0149f09 Update loofah to version 2.3.1 (#113)
90854e1 Update rubocop to version 0.75.1 (#112)

"Validation failed: Favoritable must exist"

For any model with acts_as_favoritable included, and with a user model that has acts_as_favoritor included, I get a "Validation failed: Favoritable must exist" under all circumstances, regardless of the user or model selected. The objects are persisted, and this problem happens in the console. I've tried remove everything else from either model in case there were conflicts but the same happens.

I'm using the repo's latest, and Rails 5.2.3. I'm not sure where to go from here!

Issue with scope string

Hi there,
I'm trying to use this gem in my project and I noticed a strange behavior in the Favoritor methods.
I could favorite a favoritable item successfully but I couldn't get the favorites_count, remove_favorite or favorited? results.
after some checking, I found that the scope string is saved "favorite" in the database but when trying to select from the Favorite table you pass the string "Favorite" which means you'll get 0 results as the strings are not identical.

Thank you.

undefined local variable or method `scope' when cache is used

[10] pry(main)> ActsAsFavoritor::VERSION
=> "4.0.0"
[11] pry(main)> ActsAsFavoritor.configuration.default_scope
=> :favorite
[12] pry(main)> ActsAsFavoritor.configuration.cache
=> true
[13] pry(main)> User.last.favorite Product.last
NameError: undefined local variable or method `scope' for #<User:0x00007fac321e9cf0>
from /Users/foo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/activemodel-5.2.3/lib/active_model/attribute_methods.rb:430:in `method_missing'

I think something is up here:

https://github.com/jonhue/acts_as_favoritor/blob/master/lib/acts_as_favoritor/favoritor.rb#L133

No favoritors/favorited? returns False after inserting Favorite.

This is simply not working for me. Console seems to say that favorites are created, but there's nothing then when I try to retrieve it.

`Created database 'db/test.sqlite3'
-- create_table("favorites", {:force=>:cascade})
-> 0.0625s
-- create_table("resources", {:force=>:cascade})
-> 0.0318s
-- create_table("users", {:force=>:cascade})
-> 0.0307s
-- create_table("favorites", {:force=>:cascade})
-> 0.0693s
-- create_table("resources", {:force=>:cascade})
-> 0.0274s
-- create_table("users", {:force=>:cascade})
-> 0.0322s
ec2-user:~/environment/knowhow (adding-save) $ rails console
Running via Spring preloader in process 6072
Loading development environment (Rails 5.2.0)

resource = Resource.first
Resource Load (0.2ms) SELECT "resources".* FROM "resources" ORDER BY "resources"."id" ASC LIMIT ? [["LIMIT", 1]]
=> #<Resource id: 1, title: "WaniKani", url: "https://www.wanikani.com/", content: "Learn over 2000 Japanese Kanji over the course of ...", created_at: "2018-06-10 20:05:29", updated_at: "2018-06-10 20:05:29">
user = User.first
User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT ? [["LIMIT", 1]]
=> #<User id: 1, email: "[email protected]", created_at: "2018-06-10 20:05:52", updated_at: "2018-06-10 20:05:52">
user.favorite resource
Favorite Load (0.2ms) SELECT "favorites".* FROM "favorites" WHERE "favorites"."favoritor_id" = ? AND "favorites"."favoritor_type" = ? AND "favorites"."favoritable_id" = ? AND "favorites"."favoritable_type" = ? AND "favorites"."scope" = ? ORDER BY "favorites"."id" ASC LIMIT ? [["favoritor_id", 1], ["favoritor_type", "User"], ["favoritable_id", 1], ["favoritable_type", "Resource"], ["scope", "favorite"], ["LIMIT", 1]]
(0.1ms) begin transaction
Resource Load (0.1ms) SELECT "resources".* FROM "resources" WHERE "resources"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
Favorite Create (2.2ms) INSERT INTO "favorites" ("favoritable_type", "favoritable_id", "favoritor_type", "favoritor_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["favoritable_type", "Resource"], ["favoritable_id", 1], ["favoritor_type", "User"], ["favoritor_id", 1], ["created_at", "2018-06-10 20:06:21.177285"], ["updated_at", "2018-06-10 20:06:21.177285"]]
(7.9ms) commit transaction
=> #<Favorite id: 1, favoritable_type: "Resource", favoritable_id: 1, favoritor_type: "User", favoritor_id: 1, scope: "favorite", blocked: false, created_at: "2018-06-10 20:06:21", updated_at: "2018-06-10 20:06:21">

user.favorited? resource
(0.3ms) SELECT COUNT() FROM "favorites" WHERE "favorites"."blocked" = ? AND "favorites"."scope" = ? AND "favorites"."favoritor_id" = ? AND "favorites"."favoritor_type" = ? AND "favorites"."favoritable_id" = ? AND "favorites"."favoritable_type" = ? [["blocked", 0], ["scope", "Favorite"], ["favoritor_id", 1], ["favoritor_type", "User"], ["favoritable_id", 1], ["favoritable_type", "Resource"]]
=> false
resource.favoritors_count
(0.2ms) SELECT COUNT(
) FROM "favorites" WHERE "favorites"."favoritable_id" = ? AND "favorites"."favoritable_type" = ? AND "favorites"."blocked" = ? AND "favorites"."scope" = ? [["favoritable_id", 1], ["favoritable_type", "Resource"], ["blocked", 0], ["scope", "Favorite"]]
=> 0

Release 4.0.3

2b5250a [#107] Release workflow (#109)
87fc798 [#106] CI workflow (#108)
234883d Update rspec-rails to version 3.9.0 (#105)
0740858 Update factory_bot to version 5.1.1 (#104)
0505216 Bump rubyzip from 1.2.2 to 1.3.0 in /spec/support/rails_app (#103)
a30188b Update rubocop: 0.74.0 โ†’ 0.75.0 (major) (#102)
80ed33f Update rubocop-rspec to version 1.36.0 (#101)
505fd70 Update factory_bot to version 5.1.0 (#100)
d3cdd59 Update all of rails: 5.2.3 โ†’ 6.0.0 (major) (#96)
dc8d7aa Bump nokogiri from 1.10.3 to 1.10.4 in /spec/support/rails_app (#97)
b5ad5d8 Update nokogiri to version 1.10.4 (#95)
862bb61 Update rubocop-rspec to version 1.35.0 (#94)
403c64f Update rubocop-rspec to version 1.34.1 (#93)
79514db Update rubocop-rspec to version 1.34.0 (#92)
fb8366b Update rubocop to version 0.73.0 (#91)
8c02b60 Update rubocop to version 0.72.0 (#90)
d41bcc7 Update rubocop to version 0.71.0 (#89)
8979bc8 Update rubocop to version 0.70.0 (#88)
f55f9ba [#85] Fix auto merge (#86)

favorited_by_type and return type

Hi,

So in 2.1.2 favorited_by_type used to return an active record relationship object and we could do stuff like User.favorited_by_type('Product', scopes: [:foo]).not_deleted.enabled. How do we do this now ?

Now it's returning an array and i didn't see this in the breaking changes changelog AFAIK

Also README says you can pass :limit and :order parameters https://github.com/jonhue/acts_as_favoritor#acts_as_favoritor-methods, but i think that got killed as well.

I filled this as a bug but might a documentation update depending your intentions.

Recalculate caching value

Is your feature request related to a problem? Please describe.
I enable caching feature after my app already runs on production for some time. Because of that, the caching value doesn't reflect the true number

Describe the solution you'd like
A method/rake task to recalculate all caching values

Undefined local variable or method `favoritable' when using caching

[10] pry(main)> ActsAsFavoritor::VERSION
=> "4.0.0"
[11] pry(main)> ActsAsFavoritor.configuration.default_scope
=> :favorite
[12] pry(main)> ActsAsFavoritor.configuration.cache
=> true
[13] pry(main)> User.last.favorite Product.last
NameError: undefined local variable or method `favoritable' for #<User:0x00007ff366a70b00>
from /Users/foo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/activemodel-5.2.3/lib/active_model/attribute_methods.rb:430:in `method_missing'

`#favorited?` does not work

Describe the bug
This method returns false when it really is true.

# Returns true if this instance has favorited the object passed as an
# argument.
def favorited?(favoritable, options = {})
if options.key?(:multiple_scopes) == false
options[:parameter] = favoritable
validate_scopes(__method__, options)
elsif options[:multiple_scopes]
results = {}
options[:scope].each do |scope|
results[scope] = Favorite.unblocked.send(scope + '_list')
.for_favoritor(self)
.for_favoritable(favoritable).count
.positive?
end
results
else
Favorite.unblocked.send(options[:scope] + '_list').for_favoritor(self)
.for_favoritable(favoritable).count.positive?
end
end

To Reproduce
Steps to reproduce the behavior:

  1. Setup as normal and use the method
    showterm example: http://showterm.io/7e6c76d697f66da491df5#

Expected behavior
Should return true if the favoritor has favorited the favoritable object.

Additional context
If you swap the logic out with acts_as_follower's code at https://github.com/tcocca/acts_as_follower/blob/master/lib/acts_as_follower/follower.rb#L20 and reboot your server, it returns true as expected.

def favorited?(favoritable)
    0 < Favorite.unblocked.for_favoritor(self).for_favoritable(favoritable).count
end

remove_favorite raise an error when cache is enabled

remove_favorite raise NoMethodError when cache is enabled and method called on object that is not liked
tv - acts_as_favoritable
u - acts_as_favoritor

To Reproduce

u.favorite(tv) # Ok
u.remove_favorite(tv) # Ok
u.remove_favorite(tv) # Fail
NoMethodError: undefined method `-' for nil:NilClass

gem 0.2.1

Not working with Rails 5.2

It does not works with Rails 5.2 as it use ApplicationRecord as base class for models instead of ActiveRecord::Base. So I get undefined method 'relation_delegate_class' error when use it with my models. But it works good with models derived from ActiveRecord::Base. I really do not know how to fix that

Can't uninstall this gem properly.

I'm having trouble removing this gem from my project as it was not working for me. After removing from my gemfile and bundling, and destroying the model, database migrations no longer work and throw me this erro

NameError: uninitialized constant ActsAsFavoritor /usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:43:in load_missing_constant'
/home/ec2-user/environment/knowhow/config/initializers/acts_as_favoritor.rb:1:in <main>' /usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in load'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in load' /home/ec2-user/environment/knowhow/config/environment.rb:5:in

'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in require' /usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in block in require_with_bootsnap_lfi'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in register' /usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in require_with_bootsnap_lfi'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in require' /usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in require'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in block in require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in register'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in require'
/home/ec2-user/environment/knowhow/bin/rails:9:in <top (required)>' /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in load'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in call' /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in call'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in run' /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in <top (required)>'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in load' /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in <top (required)>'
/home/ec2-user/environment/knowhow/bin/spring:15:in require' /home/ec2-user/environment/knowhow/bin/spring:15:in <top (required)>'
bin/rails:3:in load' bin/rails:3:in '
Tasks: TOP => db:reset => db:drop => db:load_config => environment`

Release 3.0.0

There aren't any new features in this release.

Breaking changes:

  • :scope option was renamed to :scopes
  • removed *_count methods

scope capitalized within #favorited_by? and # favorited?

Describe the bug

#favorited_by? and #favorited? are not working for me. I believe it is because the scope is being capitalized somewhere within #favorited_by? and # favorited?.
I'm using the default scope. If I change the default scope to anything else, it also gets capitalized. When I change the default scope to a capitalized word, the methods work as expected.

Screenshots
If applicable, add screenshots to help explain your problem.

fav-scope-bug

Additional context
This might be related to #32

Validation failed: Favoritor must exist

Screenshot from 2019-05-18 10-31-23

Hello. I have this problem and I do not know how to fix it. In the past, it worked smoothly but now something has happened.
In the Profile model, I have acts_as_favoritor and in the Job model, I have acts_as_favoritable. Both current_profile and job is not nil or something.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.