acccessing ticket.body (using Ruby API wrapper)

Krister Axel's Avatar

Krister Axel

13 Nov, 2008 10:17 PM

ok, so far so good, I'm using an API token, I can access the right project.tickets, and when I do an inspect on an iteration of ticket, I get:

<Lighthouse::Ticket:0x24fea3c @attributes={"permalink"=>"111508-partners-on-sale-in-new-locations", "updated_at"=>Mon Nov 10 19:58:38 UTC 2008, "title"=>"11/15/08 - Partners on sale in new locations", "number"=>72, "creator_id"=>35396, "tag"=>"framework", "attachments_count"=>1, "priority"=>17, "closed"=>false, "user_id"=>29791, "assigned_user_id"=>29791, "milestone_id"=>22088, "created_at"=>Thu Nov 06 17:37:05 UTC 2008, "state"=>"open"}, @prefix_options={:project_id=>15923}>

where is the body?

I need to access the actual body of the ticket, any suggestions?

  1. 1 Posted by Rick on 13 Nov, 2008 10:46 PM

    Rick's Avatar

    The body attribute is a special case, because ActiveResource would basically send the same value if all you did was change the state. You can get the comment history of a ticket if you find a single ticket:

    ticket = Lighthouse::Ticket.find 1, :params => {:project_id => 1}
    ticket.versions.each do |version|
      puts version.body
    end
    
  2. 2 Posted by Krister Axel on 13 Nov, 2008 11:12 PM

    Krister Axel's Avatar

    great, thanks for the prompt and helpful response!

    that was all I needed. :)

  3. 3 Posted by paul (at 8thlig... on 11 Dec, 2008 09:44 PM

    paul (at 8thlight)'s Avatar

    That is exactly the code I want, but I always get this error

    undefined method ‘versions’ for #<Lighthouse::Ticket:0x580d04> (on the ticket.versions line)

    when running your code against the following code

    projects = Lighthouse::Project.find(:all) project = projects[0]

    tickets = Lighthouse::Ticket.find :all, :params => {:project_id => project.id} ticket = tickets[0] puts "ticket.title: #{ticket.title}" ticket.versions.each do |version| puts version.body end

  4. 4 Posted by paul (at 8thlig... on 12 Dec, 2008 04:59 PM

    paul (at 8thlight)'s Avatar

    I figured out what my problem is. When you get tickets as an array of tickets, they don't have versions. You have to do a search for the specific ticket to get the version information.

  5. brandi closed this discussion on 29 Jun, 2012 10:04 PM.

Discussions are closed to public comments.
If you need help with Lighthouse please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac