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
4 changes: 4 additions & 0 deletions lib/model_probe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def fixture_columns
end
end

def action_text_relations
name.constantize.rich_text_association_names
end

def ddl
config = connection_db_config.configuration_hash
@ddl ||= begin
Expand Down
5 changes: 5 additions & 0 deletions lib/model_probe/templates/model.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class <%= name -%> < <%= superclass_name %>
<%= "belongs_to :#{column.name.sub(/_id\z/, "")}" %>
<% end -%>

# Action text attributes ....................................................................................
<% action_text_relations.each do |column| -%>
<%= "has_rich_text :#{column.name.sub(/_id\z/, "")}" %>
<% end -%>

# validations ..............................................................................................
<% validation_columns.each do |column| -%>
<%= "validates :#{column.name}, presence: true" unless column.null if required_columns.include?(column) %>
Expand Down