Printing “Things” in The Project

The Project will allow users to create and edit something I call “Things” in this article. One feature that is quite high on the priority list is to be able to print Things. I found the article “Print this page” with Ruby on Rails but I wanted a separate page for printing a Thing. I have created a layout called “print” and my ThingsController contains a method like this:

  def print
    @thing = current_user.things.find(params[:id])
    render :layout => "print"
  end

My routes.rb contains something like:

  map.print_thing '/things/:id/print',
    :controller => 'things', :action => 'print'

The print layout is currently bare-bone HTML with this script snippet right before </body>:

<script type="text/javascript">javascript:print()</script>

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.