Class: MonitorshipsController

Inherits:
BaseController show all
Defined in:
app/controllers/monitorships_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#advertise, #cache_action?, #css_help, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index

Methods included from LocalizedApplication

#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale

Methods included from AuthenticatedSystem

#login_by_token, #update_last_seen_at

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
# File 'app/controllers/monitorships_controller.rb', line 4

def create
  @monitorship = Monitorship.find_or_initialize_by_user_id_and_topic_id(current_user.id, params[:topic_id])
  @monitorship.update_attribute :active, true
  respond_to do |format| 
    format.html { redirect_to forum_topic_path(params[:forum_id], params[:topic_id]) }
    format.js
  end
end

#destroyObject



13
14
15
16
17
18
19
# File 'app/controllers/monitorships_controller.rb', line 13

def destroy
  Monitorship.update_all ['active = ?', false], ['user_id = ? and topic_id = ?', current_user.id, params[:topic_id]]
  respond_to do |format| 
    format.html { redirect_to forum_topic_path(params[:forum_id], params[:topic_id]) }
    format.js
  end
end