views:

67

answers:

1

Hi, I am trying out Prince with the Princely plugin, which is supposed to format templates that have the .pdf into a PDF generator.

Here is my controller:

class TodoController < ApplicationController

  def show_date
    @date = Date.today

    @campaigns = Campaign.all

    @contacts = Contact.all

    @contacts.each do |contact|

    end

    respond_to do |format|
      format.html
      format.pdf do
        render :pdf => "filename", :stylesheets => ["application", "prince"], :layout => "pdf"
      end
    end
  end

end

I changed the routes.db to include the following:

map.connect ':controller/:action.:format'

  map.todo "todo/today",
            :controller => "todo",
            :action => "show_date"

My expected behavior is when I enter todo/today.pdf, it tries to execute show_date, but renders according to the princely plugin.

Right now, it says cannot find action. What do I need to do to fix this?

A: 

You need to move the default route line (the first map.connect) below the map.todo line.

routes.rb is matching the first rule and looking for a today action.

MattMcKnight
Yes, the <code>map.connect</code> is below the map.todo ... do I need to explicitly state the template? I thought it would use the same name as the Action....
Angela
btw, how'd you put the map.connect in code-format?
Angela
Oh, maybe you have a map.resources line in there somewhere?In an entry or an answer, but not a comment, you can highlight the part of your text that is code and then click on the little binary button to give it code highlighting.
MattMcKnight