lib/generators/koudoku/install_generator.rb in koudoku-0.0.4 vs lib/generators/koudoku/install_generator.rb in koudoku-0.0.5
- old
+ new
@@ -8,11 +8,11 @@
module Koudoku
class InstallGenerator < Rails::Generators::Base
# Not sure what this does.
- source_root File.expand_path("../templates", __FILE__)
+ source_root File.expand_path("../../../../app/views/koudoku/subscriptions", __FILE__)
include Rails::Generators::Migration
argument :subscription_owner_model, :type => :string, :required => true, :desc => "Owner of the subscription"
desc "Koudoku installation generator"
@@ -40,11 +40,11 @@
# Generate subscription.
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")
+ generate("model", "plan name:string stripe_id:string price:float features:text highlight:boolean display_order:integer")
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"
@@ -52,12 +52,17 @@
# 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"
# 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"
+
+ # Install the pricing table.
+ ["_social_proof.html.erb"].each do |file|
+ copy_file "#{}file", "app/views/koudoku/subscriptions/#{file}"
+ end
# Add webhooks to the route.
- 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"
+ 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 match 'pricing' => 'koudoku::subscriptions#index', as: 'pricing'\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