I'm new to Rails...using RubyMine as an IDE.
I have Paper_Trail saving previous versions of the data "xoi_qb". My
view is currently showing the current and previous data as I'd like, but
I would like to show the diff between the current version "xoi_qb" and
the previous version "xoi_qb". For instance, the current version may be
"97" and the previous version may be "94", and I would like to display
"+3". I would like to display this difference and add the "+" or "-"
based on the positive or negative change.
In my model, Paper Trail is set to create versions like this:
def get_xoi_qb
xoi_qb = [ ]
self.versions.each do |version|
unless version.reify.nil?
xoi_qb << version.reify.xoi_qb
end
end
return xoi_qb
end
And in my HTML set to display the versions like this:
<th>Previous XOI</th>
<table>
<% @quarterback.versions.each do |version| %>
<tr>
<td><%= version.reify.xoi_qb %> dated <%= version.created_at
%></td>
</tr>
<% end %>
Not sure how to show the difference between the two versions.
Really appreciate the help.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b3e22e5b73b4bc08835d4895f438d060%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment