Class: ShopifyApp::Generators::UserModelGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/shopify_app/user_model/user_model_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dir) ⇒ Object

for generating a timestamp when using ‘create_migration`



64
65
66
# File 'lib/generators/shopify_app/user_model/user_model_generator.rb', line 64

def next_migration_number(dir)
  ActiveRecord::Generators::Base.next_migration_number(dir)
end

Instance Method Details

#create_scopes_storage_in_user_modelObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/shopify_app/user_model/user_model_generator.rb', line 21

def create_scopes_storage_in_user_model
  scopes_column_prompt = "    It is highly recommended that apps record the access scopes granted by \\\n    merchants during app installation. See app/models/user.rb to modify how \\\n    access scopes are stored and retrieved.\n\n    [WARNING] You will need to update the access_scopes accessors in the User model \\\n    to allow shopify_app to store and retrieve scopes when going through OAuth.\n\n    The following migration will add an `access_scopes` column to the User model. \\\n    Do you want to include this migration? [y/n]\n  PROMPT\n\n  if new_shopify_cli_app? || Rails.env.test? || yes?(scopes_column_prompt)\n    migration_template(\n      'db/migrate/add_user_access_scopes_column.erb',\n      'db/migrate/add_user_access_scopes_column.rb'\n    )\n  end\nend\n"

#create_user_fixturesObject



46
47
48
# File 'lib/generators/shopify_app/user_model/user_model_generator.rb', line 46

def create_user_fixtures
  copy_file('users.yml', 'test/fixtures/users.yml')
end

#create_user_migrationObject



17
18
19
# File 'lib/generators/shopify_app/user_model/user_model_generator.rb', line 17

def create_user_migration
  migration_template('db/migrate/create_users.erb', 'db/migrate/create_users.rb')
end

#create_user_modelObject



13
14
15
# File 'lib/generators/shopify_app/user_model/user_model_generator.rb', line 13

def create_user_model
  copy_file('user.rb', 'app/models/user.rb')
end

#update_shopify_app_initializerObject



42
43
44
# File 'lib/generators/shopify_app/user_model/user_model_generator.rb', line 42

def update_shopify_app_initializer
  gsub_file('config/initializers/shopify_app.rb', 'ShopifyApp::InMemoryUserSessionStore', 'User')
end