Sha256: 7c31226996fd90bf3dc5c3682eea5f59245bcde62842def8581f80aac42b9005

Contents?: true

Size: 342 Bytes

Versions: 11

Compression:

Stored size: 342 Bytes

Contents

class Book < ActiveRecord::Base
  # Rolify Gem
  resourcify

  # FriendlyId Gem
  extend FriendlyId
  friendly_id :title, use: [:slugged, :method_scopes], scope_methods: :also_written_by

  def authors
    Author.with_role(:author, self)
  end

  def also_written_by
    Book.where(id: authors.collect { |o| o.books.ids }.flatten )
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
friendly_id-method_scopes-0.3.7 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.3.3 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.3.2 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.3.1 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.3.0 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.2.6 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.2.5 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.1.8 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.1.7 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.1.6 spec/dummy/app/models/book.rb
friendly_id-method_scopes-0.1.5 spec/dummy/app/models/book.rb