-
Notifications
You must be signed in to change notification settings - Fork 684
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit 2ac5a76.
- Loading branch information
Showing
28 changed files
with
629 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
lib/generators/shopify_app/user_model/templates/db/migrate/create_users.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class CreateUsers < ActiveRecord::Migration[<%= rails_migration_version %>] | ||
def self.up | ||
create_table :users do |t| | ||
t.bigint :shopify_user_id, null: false | ||
t.string :shopify_domain, null: false | ||
t.string :shopify_token, null: false | ||
t.timestamps | ||
end | ||
|
||
add_index :users, :shopify_user_id, unique: true | ||
end | ||
|
||
def self.down | ||
drop_table :users | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class User < ActiveRecord::Base | ||
include ShopifyApp::SessionStorage | ||
|
||
def api_version | ||
ShopifyApp.configuration.api_version | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
regular_user: | ||
shopify_domain: 'regular-shop.myshopify.com' | ||
shopify_token: 'token' | ||
shopify_user_id: 1 |
38 changes: 38 additions & 0 deletions
38
lib/generators/shopify_app/user_model/user_model_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'rails/generators/base' | ||
require 'rails/generators/active_record' | ||
|
||
module ShopifyApp | ||
module Generators | ||
class UserModelGenerator < Rails::Generators::Base | ||
include Rails::Generators::Migration | ||
source_root File.expand_path('../templates', __FILE__) | ||
|
||
def create_user_model | ||
copy_file 'user.rb', 'app/models/user.rb' | ||
end | ||
|
||
def create_user_migration | ||
migration_template 'db/migrate/create_users.erb', 'db/migrate/create_users.rb' | ||
end | ||
|
||
def update_shopify_app_initializer | ||
gsub_file 'config/initializers/shopify_app.rb', 'ShopifyApp::InMemorySessionStore', 'User' | ||
end | ||
|
||
def create_user_fixtures | ||
copy_file 'users.yml', 'test/fixtures/users.yml' | ||
end | ||
|
||
private | ||
|
||
def rails_migration_version | ||
Rails.version.match(/\d\.\d/)[0] | ||
end | ||
|
||
# for generating a timestamp when using `create_migration` | ||
def self.next_migration_number(dir) | ||
ActiveRecord::Generators::Base.next_migration_number(dir) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.