Class: UsefullAttachment::LinksController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- UsefullAttachment::LinksController
- Defined in:
- app/controllers/usefull_attachment/links_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/usefull_attachment/links_controller.rb', line 13 def create ##UserSession.log("Admin::AttachmentController#create params=#{params[:admin_attachment].inspect}") user = current_user ? {:created_by => current_user.id, :updated_by => current_user.id} : {} Attachment.create(params[:usefull_attachment_attachment].deep_merge!(user)) if params[:usefull_attachment_attachment].present? Avatar.create(params[:usefull_attachment_avatar].deep_merge!(user)) if params[:usefull_attachment_avatar].present? Link.create(params[:usefull_attachment_link].deep_merge!(user)) if params[:usefull_attachment_link].present? redirect_to :action => "index", :notice => t("created") rescue => e flash[:alert] = t("not_created", :message => e.) redirect_to :back end |
#destroy ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/usefull_attachment/links_controller.rb', line 38 def destroy = Link.find(params[:id]) .destroy respond_to do |format| format.html do redirect_to :back, :notice => t("deleted") end format.xml { head :ok } end rescue => e flash[:alert] = t("not_deleted", :message => e.) redirect_to :back end |
#download ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/usefull_attachment/links_controller.rb', line 25 def download = Link.find(params[:id]) respond_to do |format| format.html do raise FileMissing.new(:file => .link.path) unless File.exist?(.link.path) send_file .link.path, :type => .link_content_type end end rescue => e flash[:alert] = t("not_downloaded", :message => e.) redirect_to :back end |
#index ⇒ Object
3 4 5 6 |
# File 'app/controllers/usefull_attachment/links_controller.rb', line 3 def index @search = Link.search(params[:search]) = @search.paginate(:page => params[:page]) end |
#new ⇒ Object
8 9 10 11 |
# File 'app/controllers/usefull_attachment/links_controller.rb', line 8 def new = Link.new #UserSession.log("Admin::AttachmentController#new params=#{params[:admin_attachment].inspect}, @attachment=#{@attachment.inspect}") end |