validates_presence_of :body
validates_associated :diary_entry
- after_initialize :set_defaults
after_save :spam_check
def body
private
- def set_defaults
- self.body_format = "markdown" unless self.attribute_present?(:body_format)
- end
-
def spam_check
user.spam_check
end
:greater_than_or_equal_to => -180, :less_than_or_equal_to => 180
validates_associated :language
- after_initialize :set_defaults
after_save :spam_check
def body
private
- def set_defaults
- self.body_format = "markdown" unless self.attribute_present?(:body_format)
- end
-
def spam_check
user.spam_check
end
validates_inclusion_of :message_read, :in => [ true, false ]
validates_as_utf8 :title
- after_initialize :set_defaults
-
def self.from_mail(mail, from, to)
if mail.multipart?
if mail.text_part
md5 << body
md5.hexdigest
end
-
-private
-
- def set_defaults
- self.body_format = "markdown" unless self.attribute_present?(:body_format)
- end
end
has_many :old_ways
has_many :old_relations
- after_initialize :set_defaults
-
# this method overrides the AR default to provide the rich
# text object for the description field.
def description
RichText.new(read_attribute(:description_format), read_attribute(:description))
end
-
- private
-
- # set the default format to be markdown, in the absence of
- # any other setting.
- def set_defaults
- self.description_format = "markdown" unless self.attribute_present?(:description_format)
- end
end
def set_defaults
self.creation_time = Time.now.getutc unless self.attribute_present?(:creation_time)
- self.description_format = "markdown" unless self.attribute_present?(:description_format)
end
def encrypt_password
belongs_to :user, :class_name => "User", :foreign_key => :user_id
belongs_to :creator, :class_name => "User", :foreign_key => :creator_id
belongs_to :revoker, :class_name => "User", :foreign_key => :revoker_id
-
- after_initialize :set_defaults
PERIODS = USER_BLOCK_PERIODS
private
- ##
- # set default values for new records.
- def set_defaults
- self.reason_format = "markdown" unless self.attribute_present?(:reason_format)
- end
-
##
# validate that only moderators are allowed to change the
# block. this should be caught and dealt with in the controller,
--- /dev/null
+class ChangeDefaultFormats < ActiveRecord::Migration
+ def up
+ change_column_default :diary_entries, :body_format, "markdown"
+ change_column_default :diary_comments, :body_format, "markdown"
+ change_column_default :messages, :body_format, "markdown"
+ change_column_default :users, :description_format, "markdown"
+ change_column_default :user_blocks, :reason_format, "markdown"
+ end
+
+ def down
+ change_column_default :diary_entries, :body_format, "html"
+ change_column_default :diary_comments, :body_format, "html"
+ change_column_default :messages, :body_format, "html"
+ change_column_default :users, :description_format, "html"
+ change_column_default :user_blocks, :reason_format, "html"
+ end
+end
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
visible boolean DEFAULT true NOT NULL,
- body_format format_enum DEFAULT 'html'::format_enum NOT NULL
+ body_format format_enum DEFAULT 'markdown'::format_enum NOT NULL
);
longitude double precision,
language_code character varying DEFAULT 'en'::character varying NOT NULL,
visible boolean DEFAULT true NOT NULL,
- body_format format_enum DEFAULT 'html'::format_enum NOT NULL
+ body_format format_enum DEFAULT 'markdown'::format_enum NOT NULL
);
to_user_id bigint NOT NULL,
to_user_visible boolean DEFAULT true NOT NULL,
from_user_visible boolean DEFAULT true NOT NULL,
- body_format format_enum DEFAULT 'html'::format_enum NOT NULL
+ body_format format_enum DEFAULT 'markdown'::format_enum NOT NULL
);
revoker_id bigint,
created_at timestamp without time zone,
updated_at timestamp without time zone,
- reason_format format_enum DEFAULT 'html'::format_enum NOT NULL
+ reason_format format_enum DEFAULT 'markdown'::format_enum NOT NULL
);
openid_url character varying,
preferred_editor character varying,
terms_seen boolean DEFAULT false NOT NULL,
- description_format format_enum DEFAULT 'html'::format_enum NOT NULL,
+ description_format format_enum DEFAULT 'markdown'::format_enum NOT NULL,
image_fingerprint character varying,
changesets_count integer DEFAULT 0 NOT NULL,
traces_count integer DEFAULT 0 NOT NULL,
INSERT INTO schema_migrations (version) VALUES ('20140519141742');
+INSERT INTO schema_migrations (version) VALUES ('20150110152606');
+
INSERT INTO schema_migrations (version) VALUES ('21');
INSERT INTO schema_migrations (version) VALUES ('22');