I have a model Ticket which has n
Comments belonging to it (many to one relationship).
The issue is that I can not render any of the comments nor does the form post the comments to the database.
I can kinda sorta do this from irb. I can add comments to tickets.comments, but I cannot pull individual comments - I can pull up the collection but have not figured out how to do anything with it. It is a Class: DataMapper::Associations::OneToMany::Collection and documentation says "A Collection should act like an Array in every way"
So 2 issues needing reading and input:
1) posting from the web form 2) iterating over and rendering the collection through haml, which I can't seem to do.
More gory details:
I have a Sinatra method that pulls up
get '/:thisticket' do
@ticket=Ticket.first(:slug=>params[:slug])
if @ticket
haml :showticket
Haml template
%div{:class => "ticket"}
%h1
= @ticket.slug
= @ticket.comments.all (returns the # symbol to any html page)
- @ticket.comments.all do |comment|
%h4
= comment.a_comment
%h4
= comment.created_at
%h4
= comment.id (this block shows nothing on a rendered page)
%center
%form{:action => "/#{@thisticket.slug}/update", :enctype => "text/plain", :method => "post"}
comments
%br/
%textarea{:id => "a_comment",:name => "a_comment", :rows => "5"}
:preserve
%br/
%input{:type => "submit", :value => "post"}/