class ActiveRecord::Generators::RubyGalleryGenerator
Public Instance Methods
copy_ruby_gallery_migration()
click to toggle source
# File lib/generators/active_record/ruby_gallery_generator.rb, line 11 def copy_ruby_gallery_migration route "put '/#{table_name}/update_ruby_gallery_position', controller: :#{table_name}, action: :update_ruby_gallery_position" route "post '/#{table_name}/upload_album', controller: :#{table_name}, action: :upload_album" route "delete '/#{table_name}/:id/delete_photo', controller: :#{table_name}, action: :delete_photo" if migration_exists?("album_photos") && migration_add_columns_exists?("album_photos") else migration_template "album_photo_migration.rb", "db/migrate/ruby_gallery_create_album_photos" migration_template "migration.rb", "db/migrate/ruby_gallery_add_columns_to_album_photos" end end
inject_ruby_gallery_content_to_controller()
click to toggle source
# File lib/generators/active_record/ruby_gallery_generator.rb, line 30 def inject_ruby_gallery_content_to_controller content = %Q{ upload_album_for :#{table_name}} class_path = class_name.to_s.split("::") indent_depth = class_path.size - 1 content = content.split("\n").map { |line| " " * indent_depth + line } .join("\n") << "\n" inject_into_class(controller_path, class_path.last.tableize.camelize + "Controller", content) if controller_exists? end
inject_ruby_gallery_content_to_model()
click to toggle source
# File lib/generators/active_record/ruby_gallery_generator.rb, line 22 def inject_ruby_gallery_content_to_model content = %Q{ has_many :album_photos, as: :photoable} class_path = class_name.to_s.split("::") indent_depth = class_path.size - 1 content = content.split("\n").map { |line| " " * indent_depth + line } .join("\n") << "\n" inject_into_class(model_path, class_path.last, content) if model_exists? end