Class: Muck::SharesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Muck::SharesController
- Defined in:
- app/controllers/muck/shares_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/muck/shares_controller.rb', line 24 def create @share = current_user.shares.build(params[:share]) @share.save! # TODO add UI that will let the user share with specific users share_to = nil attach_to = @share.discover_attach_to rescue nil # try to find an object to attach the activity to ie an entry @share.add_share_activity(share_to, attach_to) = t('muck.shares.create_success') handle_after_create(true, ) rescue ActiveRecord::RecordInvalid => ex if @share errors = @share.errors..to_sentence else errors = ex end = t('muck.shares.create_error', :errors => errors) handle_after_create(false, ) end |
#destroy ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/muck/shares_controller.rb', line 43 def destroy @share.destroy respond_to do |format| format.html do flash[:notice] = t('muck.shares.share_removed') redirect_back_or_default(current_user) end format.js { render :template => 'shares/destroy', :layout => false } format.json { render :json => { :success => true, :message => t("muck.shares.share_removed"), :share_id => @share.id } } end end |
#index ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/controllers/muck/shares_controller.rb', line 7 def index @shares = @user.shares.by_newest respond_to do |format| format.html { render :template => 'shares/index' } format.pjs { render :template => 'shares/index', :layout => false } end end |
#new ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/controllers/muck/shares_controller.rb', line 15 def new @page_title = t('muck.shares.new_share') @share = Share.new(:uri => params[:uri] || params[:u], :title => params[:title] || params[:t], :message => params[:message] || params[:m]) respond_to do |format| format.html { render :template => 'shares/new', :layout => 'popup' } format.pjs { render :template => 'shares/new', :layout => false } end end |