Skip to content
Extraits de code Groupes Projets
Valider 71c3a29a rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Move YoutubeTitles callback into module

parent 1be28456
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -25,7 +25,6 @@ class Comment < ActiveRecord::Base ...@@ -25,7 +25,6 @@ class Comment < ActiveRecord::Base
serialize :youtube_titles, Hash serialize :youtube_titles, Hash
before_save do before_save do
get_youtube_title text
self.text.strip! unless self.text.nil? self.text.strip! unless self.text.nil?
end end
def diaspora_handle def diaspora_handle
......
...@@ -71,7 +71,7 @@ class Request ...@@ -71,7 +71,7 @@ class Request
private private
def not_already_connected def not_already_connected
if sender && recipient && Contact.where(:user_id => self.recipient.owner_id, :person_id => self.sender.id).count > 0 if sender && recipient && Contact.where(:user_id => self.recipient.owner_id, :person_id => self.sender.id).exists?
errors[:base] << 'You have already connected to this person' errors[:base] << 'You have already connected to this person'
end end
end end
......
...@@ -23,9 +23,6 @@ class StatusMessage < Post ...@@ -23,9 +23,6 @@ class StatusMessage < Post
attr_accessible :text attr_accessible :text
serialize :youtube_titles, Hash serialize :youtube_titles, Hash
before_save do
get_youtube_title text
end
before_create :build_tags before_create :build_tags
......
module YoutubeTitles module YoutubeTitles
def self.included(model)
model.class_eval do
before_save do
get_youtube_title text
end
end if model.respond_to?(:before_save)
end
def youtube_title_for video_id def youtube_title_for video_id
http = Net::HTTP.new('gdata.youtube.com', 80) http = Net::HTTP.new('gdata.youtube.com', 80)
path = "/feeds/api/videos/#{video_id}?v=2" path = "/feeds/api/videos/#{video_id}?v=2"
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter