Class: Spina::Shop::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/spina/shop/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_migrationsObject



5
6
7
8
# File 'lib/generators/spina/shop/install_generator.rb', line 5

def copy_migrations
  return if Rails.env.production?
  rake 'spina_shop:install:migrations'
end

#default_product_categoryObject



18
19
20
21
# File 'lib/generators/spina/shop/install_generator.rb', line 18

def default_product_category
  default_product_category = Spina::Shop::ProductCategory.where(name: 'Default').first_or_initialize
  default_product_category.save
end

#default_sales_categoryObject



23
24
25
26
27
28
29
30
31
# File 'lib/generators/spina/shop/install_generator.rb', line 23

def default_sales_category
  default_sales_category = Spina::Shop::SalesCategory.where(name: "Default").first_or_initialize
  default_sales_category.codes = {
    world: {
      default: "0"
    }
  }
  default_sales_category.save
end

#feedbackObject



33
34
35
36
37
38
39
40
# File 'lib/generators/spina/shop/install_generator.rb', line 33

def feedback
  puts
  puts '    Your Spina Shop has been succesfully installed! '
  puts
  puts '    Restart your server and visit http://localhost:3000 in your browser!'
  puts "    The admin backend is located at http://localhost:3000/#{Spina.config.backend_path}."
  puts
end

#import_countriesObject



14
15
16
# File 'lib/generators/spina/shop/install_generator.rb', line 14

def import_countries
  rake 'spina_shop:import_countries'
end

#run_migrationsObject



10
11
12
# File 'lib/generators/spina/shop/install_generator.rb', line 10

def run_migrations
  rake 'db:migrate'
end