Module: ArticlesHelper

Defined in:
app/helpers/articles_helper.rb

Instance Method Summary collapse

Instance Method Details

#highlight_new(unequal_attributes, attribute) ⇒ Object

useful for highlighting attributes, when synchronizing articles


4
5
6
7
# File 'app/helpers/articles_helper.rb', line 4

def highlight_new(unequal_attributes, attribute)
  return unless unequal_attributes
  unequal_attributes.has_key?(attribute) ? "background-color: yellow" : ""
end

#row_classes(article) ⇒ Object


9
10
11
12
13
14
# File 'app/helpers/articles_helper.rb', line 9

def row_classes(article)
  classes = []
  classes << "unavailable" if !article.availability
  classes << "just-updated" if article.recently_updated && article.availability
  classes.join(" ")
end

#search_paramsObject

Flatten search params, used in import from external database


17
18
19
20
# File 'app/helpers/articles_helper.rb', line 17

def search_params
  return {} unless params[:q]
  Hash[params[:q].map { |k,v| [k, (v.is_a?(Array) ? v.join(" ") : v)] }]
end