Class: DcBook
- Inherits:
-
Object
- Object
- DcBook
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/dc_book.rb
Overview
Schema information
Collection name: dc_book : Books
_id BSON::ObjectId _id
created_at Time created_at
updated_at Time updated_at
title String Book title
link String link
description String Short description of the book
active Mongoid::Boolean Active
author String Author's name
created_by BSON::ObjectId created_by
updated_by BSON::ObjectId updated_by
Instance Method Summary collapse
-
#clear_link(link) ⇒ Object
Clears subject link of chars that shouldn’t be there and also take care of its size.
- #do_before_save ⇒ Object
Instance Method Details
#clear_link(link) ⇒ Object
Clears subject link of chars that shouldn’t be there and also take care of its size
64 65 66 67 68 69 70 71 |
# File 'app/models/dc_book.rb', line 64 def clear_link(link) link.gsub!(/\.|\?|\!\&|»|«|\,|\"|\'|\:/,'') link.gsub!('<br>','') link.gsub!(' ','-') link.gsub!('---','-') link.gsub!('--','-') link end |
#do_before_save ⇒ Object
74 75 76 77 78 |
# File 'app/models/dc_book.rb', line 74 def do_before_save if self.link.empty? self.link = clear_link(self.title.downcase.strip) end end |