Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/gcm_on_rails/app/models/gcm/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
class Gcm::Device < Gcm::Base
self.table_name = "gcm_devices"

attr_accessible :registration_id

has_many :notifications, :class_name => 'Gcm::Notification', :dependent => :destroy
validates_presence_of :registration_id
validates_uniqueness_of :registration_id
Expand Down
46 changes: 25 additions & 21 deletions lib/generators/gcm_migrations_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,34 @@
# This should be run upon install and upgrade of the
# Gcm on Rails gem.
#
# $ ruby script/generate gcm_migrations
# $ ruby script/generate gcm_migrations
class GcmMigrationsGenerator < Rails::Generators::Base
include Rails::Generators::Migration
extend ActiveRecord::Generators::Migration
include Rails::Generators::Migration

# Set the current directory as base for the inherited generators.
def self.base_root
File.dirname(__FILE__)
end
# Set the current directory as base for the inherited generators.
def self.base_root
File.dirname(__FILE__)
end

source_root File.expand_path('../templates/gcm_migrations', __FILE__)
source_root File.expand_path('../templates/gcm_migrations', __FILE__)

def create_migrations
templates = {
'create_gcm_devices.rb' => 'db/migrate/create_gcm_devices.rb',
'create_gcm_notifications.rb' => 'db/migrate/create_gcm_notifications.rb'
}
def create_migrations
templates = {
'create_gcm_devices.rb' => 'db/migrate/create_gcm_devices.rb',
'create_gcm_notifications.rb' => 'db/migrate/create_gcm_notifications.rb'
}

templates.each_pair do |name, path|
begin
migration_template(name, path)
rescue => err
puts "WARNING: #{err.message}"
end
end
end

def self.next_migration_number dirname
ActiveRecord::Generators::Base.next_migration_number dirname
end

templates.each_pair do |name, path|
begin
migration_template(name, path)
rescue => err
puts "WARNING: #{err.message}"
end
end
end
end # GcmMigrationsGenerator