Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.64 KB | None | 0 0
  1.   def watcher_link(objects, user)
  2.     return '' unless user && user.logged?
  3.     objects = Array.wrap(objects)
  4.     return '' unless objects.any?
  5.  
  6.     watched = Watcher.any_watched?(objects, user)
  7.     css = [watcher_css(objects), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ')
  8.     text = watched ? l(:button_unwatch) : l(:button_watch)
  9.     url = watch_path(
  10.       :object_type => objects.first.class.to_s.underscore,
  11.       :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
  12.     )
  13.     method = watched ? 'delete' : 'post'
  14.  
  15.     link_to text, url, :remote => true, :method => method, :class => css
  16.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement