Created
September 3, 2013 14:57
-
-
Save slaith/6425027 to your computer and use it in GitHub Desktop.
item.rb error
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
class Item < ActiveRecord::Base | |
attr_accessible :name, :price, :priority,:picture,:url | |
belongs_to :user | |
validates :name, presence: true | |
validates :price, presence: true | |
validates :price, length: { :maximum => 7} | |
has_attached_file :picture,:styles => {:small => "100x100>"} | |
validates_attachment_size :picture, :less_than => 5.megabytes | |
validates :url, format: /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix | |
validates_attachment_content_type :picture, :content_type => ['image/jpeg', 'image/png'] | |
validates :price,:numericality => true, :allow_nil => true | |
#default_scope {where "completed<>trued"} | |
def source | |
[email protected]('/')[2]//This doesn't work: nilClass for url | |
hostname=self.url.split('/')[2]//This does | |
hostname["www."]="" | |
hostname.capitalize | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment