17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/models/refinery/copywriting/phrase.rb', line 17
def self.for(name, options = {})
options = {:phrase_type => 'text', :scope => 'default'}.merge(options.reject {|k,v| v.blank? })
options[:name] = name.to_s
options[:page_id] ||= options[:page].try(:id)
phrase = self.find_by_name_and_scope_and_page_id(options[:name], options[:scope], options[:page_id]) || self.create(options)
phrase.update_attributes(options.except(:value, :page, :page_id, :locale))
phrase.last_access_at = Date.today
phrase.save if phrase.changed?
phrase.default_or_value
end
|