Book Image

Redmine Plugin Extension and Development

By : Alex Bevilacqua
Book Image

Redmine Plugin Extension and Development

By: Alex Bevilacqua

Overview of this book

Table of Contents (16 chapters)
Redmine Plugin Extension and Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Controller modifications to accommodate attachments


Since we're using the standard Redmine view partials to manage our attachments, when a new article is created or updated, attachments are submitted to our controller in an attachments collection, which is available from params[:attachments]:

"attachments"=>
{"1"=>
  {"filename"=>"8748OS_04_01.png",
    "description"=>"",
    "token"=>"4.f5bd5eabd62c9ec71b427d8195f18285"},
  "2"=>
    {"filename"=>"8748OS_04_02.png",
      "description"=>"",
      "token"=>"5.f8bd02cfcb83aba081bf69ac06fdb085"},
  "3"=>
    {"filename"=>"8748OS_04_03.png",
      "description"=>"",
      "token"=>"6.80b7dd688925171341b4004fc9ddcf69"}}

The actual file uploads are handled asynchronously by Redmine before we even submit the form, but we still have to associate these files with our model.

One of the instance methods that acts_as_attachable provides our models with is save_attachments. This can be used in our controller to complete...