lib/generators/koudoku/install_generator.rb in koudoku-0.0.3 vs lib/generators/koudoku/install_generator.rb in koudoku-0.0.4
- old
+ new
@@ -27,21 +27,25 @@
api_key = SecureRandom.uuid
create_file 'config/initializers/koudoku.rb' do
<<-RUBY
Koudoku.setup do |config|
config.webhooks_api_key = "#{api_key}"
+ config.subscriptions_owned_by = :user
+ config.stripe_publishable_key = ENV['STRIPE_PUBLISHABLE_KEY']
+ config.stripe_secret_key = ENV['STRIPE_SECRET_KEY']
+ # config.free_trial_length = 30
end
RUBY
end
# Generate subscription.
- generate("model", "subscription stripe_id:string plan_id:integer last_four:string coupon_id:integer current_price:float #{subscription_owner_model}_id:integer")
+ generate("model", "subscription stripe_id:string plan_id:integer last_four:string coupon_id:integer last_four:string card_type:string current_price:float #{subscription_owner_model}_id:integer")
gsub_file "app/models/subscription.rb", /ActiveRecord::Base/, "ActiveRecord::Base\n include Koudoku::Subscription\n\n belongs_to :#{subscription_owner_model}\n belongs_to :coupon\n"
# Add the plans.
generate("model", "plan name:string stripe_id:string price:float")
- gsub_file "app/models/plan.rb", /ActiveRecord::Base/, "ActiveRecord::Base\n belongs_to :#{subscription_owner_model}\n belongs_to :coupon\n"
+ gsub_file "app/models/plan.rb", /ActiveRecord::Base/, "ActiveRecord::Base\n include Koudoku::Plan\n belongs_to :#{subscription_owner_model}\n belongs_to :coupon\n has_many :subscriptions\n"
# Add coupons.
generate("model coupon code:string free_trial_length:string")
gsub_file "app/models/plan.rb", /ActiveRecord::Base/, "ActiveRecord::Base\n has_many :subscriptions\n"
@@ -50,10 +54,10 @@
# Update the owner relationship.
gsub_file "app/models/#{subscription_owner_model}.rb", /ActiveRecord::Base/, "ActiveRecord::Base\n\n # Added by Koudoku.\n has_one :subscription\n\n"
# Add webhooks to the route.
- gsub_file "config/routes.rb", /Application.routes.draw do/, "Application.routes.draw do\n\n # Added by Koudoku.\n namespace :koudoku do\n match 'webhooks' => 'webhooks#process'\n end\n\n"
+ gsub_file "config/routes.rb", /Application.routes.draw do/, "Application.routes.draw do\n\n # Added by Koudoku.\n mount Koudoku::Engine, at: \"koudoku\"\n\n"
# Show the user the API key we generated.
say "\nTo enable support for Stripe webhooks, point it to \"/koudoku/webhooks?api_key=#{api_key}\". This API key has been randomly generated, so it's unique to your application.\n\n"
end
\ No newline at end of file