```ruby
require 'attachinary/utils'

module Attachinary
  module Extension
    include Base

    def attachinary_orm_definition(options)
      relation = "#{options[:singular]}_files"

      # has_many :photo_files, ...
      # has_many :image_files, ...
      has_many :"#{relation}",
        lambda { where(scope: options[:scope].to_s) }, 
        as: :attachinariable,
        class_name: '::Attachinary::File',
        dependent: :destroy


      # def photo=(file)
      #   input = Attachinary::Utils.process_input(input, upload_options)
      #   if input.blank?
      #     photo_files.clear
      #   else
      #     files = [input].flatten
      #     self.photo_files = files
      #   end
      # end
      define_method "#{options[:scope]}=" do |input, upload_options = {}|
        input = Attachinary::Utils.process_input(input, upload_options, options[:scope])
        if input.nil?
          send("#{relation}").clear
        else
          files = [input].flatten
          send("#{relation}=", files)
        end
      end


      if options[:single]
        # def photo
        #   photo_files.first
        # end
        define_method "#{options[:scope]}" do
          send("#{relation}").first
        end

      else # plural
        # def images
        #   image_files
        # end
        define_method "#{options[:scope]}" do
          send("#{relation}")
        end
      end

    end

  end
end
```

Update lambda to scope for Rails 4 ActiveModel syntax
user
```ruby
require 'attachinary/utils'

module Attachinary
  module Extension
    include Base

    def attachinary_orm_definition(options)
      relation = "#{options[:singular]}_files"

      # has_many :photo_files, ...
      # has_many :image_files, ...
      has_many :"#{relation}",
        -> { where scope: options[:scope].to_s }, 
        as: :attachinariable,
        class_name: '::Attachinary::File',
        dependent: :destroy


      # def photo=(file)
      #   input = Attachinary::Utils.process_input(input, upload_options)
      #   if input.blank?
      #     photo_files.clear
      #   else
      #     files = [input].flatten
      #     self.photo_files = files
      #   end
      # end
      define_method "#{options[:scope]}=" do |input, upload_options = {}|
        input = Attachinary::Utils.process_input(input, upload_options, options[:scope])
        if input.nil?
          send("#{relation}").clear
        else
          files = [input].flatten
          send("#{relation}=", files)
        end
      end


      if options[:single]
        # def photo
        #   photo_files.first
        # end
        define_method "#{options[:scope]}" do
          send("#{relation}").first
        end

      else # plural
        # def images
        #   image_files
        # end
        define_method "#{options[:scope]}" do
          send("#{relation}")
        end
      end

    end

  end
end
```
assistant