forked from jamesgolick/timeline_fu
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dariusz Gertych
committed
Jan 12, 2011
1 parent
aea06b7
commit d86c0ab
Showing
3 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pkg | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Generates both the TimelineEvent class and the migration to create its table. The table will have subject, actor and secondary actor as polymorphic associations. | ||
The use of this generator is optional. See README for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'rails/generators' | ||
require 'rails/generators/migration' | ||
|
||
class TimelineFuGenerator < Rails::Generators::Base | ||
include Rails::Generators::Migration | ||
source_root File.expand_path(File.join('..', '..', '..', 'generators', 'timeline_fu', 'templates'), File.dirname(__FILE__)) | ||
|
||
|
||
def self.next_migration_number(dirname) | ||
if ActiveRecord::Base.timestamped_migrations | ||
Time.now.utc.strftime("%Y%m%d%H%M%S") | ||
else | ||
"%.3d" % (current_migration_number(dirname) + 1) | ||
end | ||
end | ||
|
||
def create_migration_file | ||
copy_file 'model.rb', 'app/models/timeline_event.rb' | ||
migration_template 'migration.rb', 'db/migrate/create_timeline_events.rb' | ||
end | ||
end |