Sha256: 58721223eeb863b12ce0ddb8b234e43df2b834cf373947c957334691f3555498

Contents?: true

Size: 774 Bytes

Versions: 52

Compression:

Stored size: 774 Bytes

Contents

# frozen-string-literal: true
require "rails/generators"

module Mobility
  module BackendGenerators
    class TableBackend < Mobility::BackendGenerators::Base
      source_root File.expand_path("../../templates", __FILE__)

      def create_migration_file
        if data_source_exists? && !self.class.migration_exists?(migration_dir, migration_file)
          migration_template "#{backend}_migration.rb", "db/migrate/#{migration_file}.rb"
        else
          super
        end
      end

      private

      alias_method :model_table_name, :table_name
      def table_name
        model_table_name = super
        "#{model_table_name.singularize}_translations"
      end

      def foreign_key
        "#{model_table_name.singularize}_id"
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
mobility-0.8.3 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.8.2 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.8.1 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.8.0 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.7.6 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.7.5 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.7.4 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.7.3 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.7.2 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.7.1 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.7.0 lib/rails/generators/mobility/backend_generators/table_backend.rb
mobility-0.6.0 lib/rails/generators/mobility/backend_generators/table_backend.rb