class Sufia::Models::UserStatsGenerator
Public Instance Methods
add_stats_mixin_to_user_model()
click to toggle source
# File lib/generators/sufia/models/user_stats_generator.rb, line 20 def add_stats_mixin_to_user_model file_path = "app/models/#{model_name.underscore}.rb" if File.exist?(file_path) inject_into_file file_path, after: /include Sufia\:\:User.*$/ do "\n include Sufia::UserUsageStats" end else puts " \e[31mFailure\e[0m Sufia requires a user object. This generator assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails g sufia:models:user_stats client" end end
copy_migrations()
click to toggle source
Setup the database migrations
# File lib/generators/sufia/models/user_stats_generator.rb, line 16 def copy_migrations better_migration_template 'create_user_stats.rb' end