mattvanhorn/BJJLife

View on GitHub
lib/strategies/user_authored_strategy.rb

Summary

Maintainability
A
0 mins
Test Coverage
class UserAuthoredStrategy < DecentExposure::ActiveRecordWithEagerAttributesStrategy
  delegate :current_user, :to => :controller

  def resource
    instance = super

    unless plural?
      if instance.new_record?
        instance.user ||= current_user.to_model
      end
    end
    instance
  end

end