This file contains hidden or 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
| #!/usr/bin/env ruby | |
| # Please read http://otobrglez.opalab.com for more information about this code. | |
| class Book < Struct.new(:title) | |
| def words | |
| @words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort | |
| end |
This file contains hidden or 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
| #http://blog.wyeworks.com/2009/7/13/paperclip-file-rename | |
| Paperclip.interpolates :default_image_type do |attachment, style| | |
| attachment.instance.get_user_default_profile_image | |
| end | |
| Paperclip.interpolates :normalized_avatar_file_name do |attachment, style| | |
| attachment.instance.normalized_avatar_file_name | |
| end | |
This file contains hidden or 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
| # Basic Code | |
| class Image | |
| has_attached_file :attachment | |
| def attachment_url(url) | |
| require "open-uri" | |
| self.attachment = open(url) | |
| end | |
| end |
NewerOlder