class Remotty::Rails::Generators::InstallGenerator
마이그레이션 생성 및 각종 클래스&설정 추가 및 변경
migration¶ ↑
-
add_column_to_users.rb
- user -
create_auth_tokens.rb
- auth token -
create_oauth_authentications.rb
- oauth authentication
model¶ ↑
-
auth_token.rb
- auth token -
oauth_authentication.rb
- oauth_authentication -
user.rb
- user model에 base include
configuration¶ ↑
-
paperclip_hash.rb
- paperclip hash
serializer¶ ↑
-
user_serializer.rb
- user model serializer
controller¶ ↑
-
application_controller.rb
- application controller에 base include
Public Class Methods
next_migration_number(path)
click to toggle source
migration number는 현재날짜시간 + index(1,2,…) 형식으로 생성함
# File lib/generators/remotty/rails/install_generator.rb, line 38 def self.next_migration_number(path) @migration_index += 1 (Time.now.utc.strftime("%Y%m%d%H%M%S").to_i + @migration_index).to_s end
Public Instance Methods
copy_purple_attachment()
click to toggle source
add & update files
# File lib/generators/remotty/rails/install_generator.rb, line 44 def copy_purple_attachment template 'auth_token.rb', 'app/models/auth_token.rb' template 'oauth_authentication.rb', 'app/models/oauth_authentication.rb' template 'user_serializer.rb', 'app/serializers/user_serializer.rb' template 'paperclip_hash.rb', 'config/initializers/paperclip_hash.rb' append_to_file 'config/initializers/paperclip_hash.rb' do secret = SecureRandom.hex(40) "Paperclip::Attachment.default_options.update({ :hash_secret => '#{secret}' })" end inject_into_class 'app/controllers/application_controller.rb', ApplicationController do " include Remotty::BaseApplicationController\n" end inject_into_class 'app/models/user.rb', User do " include Remotty::BaseUser\n" end gsub_file 'app/models/user.rb', 'registerable', 'registerable, :confirmable, :omniauthable' migration_template 'add_column_to_users.rb', 'db/migrate/add_column_to_users.rb' migration_template 'create_auth_tokens.rb', 'db/migrate/create_auth_tokens.rb' migration_template 'create_oauth_authentications.rb', 'db/migrate/create_oauth_authentications.rb' end