Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question Controller and views for Expanded Q & A system #550

Merged
merged 2 commits into from May 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/assets/stylesheets/style.css
Expand Up @@ -224,6 +224,8 @@ body { padding-top: 70px; }

#tags .label {
line-height: 2em;
font-size: 13px;
margin-right: 4px;
}

/* Styles for specific areas of the site */
Expand Down Expand Up @@ -342,3 +344,29 @@ div.note.moderated h4 {
background: none;
font-size: smaller;
}

.question{
color: #aaa;
font-style: italic;
}
.question + a{
text-decoration: none;
}

.inline{
display: inline-block;
}

.inline img.img-circle{
vertical-align: baseline;
width: 35px;
margin-right: 6px;
}

.inline div.img-circle{
vertical-align: middle;
height: 35px;
width: 35px;
margin-right: 6px;
background: #ccc;
}
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -80,7 +80,7 @@ def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to login_url+'?return_to=' + URI.encode(request.env['PATH_INFO'])
redirect_to login_url
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, wait - why was this removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the store_location method already stores the full path of the request in the session. See reference here: https://github.com/publiclab/plots2/pull/550/files#diff-55c5b7aecfb519d0e4880eaf2788eb6eL98. The URI.encode(request.env['PATH_INFO']) was actually returning the parameters but it was only available to \login page. As soon it posted the login parameters of an user the parameters were no longer available and it didn't redirect to with no parameters in the /post url. So it was an issue that I solved it here using the changes done in the user_sessions_controller: https://github.com/publiclab/plots2/pull/550/files#diff-0770692f348632e109afe78e3585bfe0R35

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see -- great, thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, perhaps smaller, independent changes could be submitted in separate pull requests, however, where possible. Thanks, though, this is a good catch and a welcome contribution!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a issue I should have handled separately raising a github issue.Will do it as per from the next time. Thanks Jeff!

return false
end
end
Expand Down
12 changes: 10 additions & 2 deletions app/controllers/notes_controller.rb
Expand Up @@ -103,7 +103,11 @@ def create
else
flash[:notice] = "Research note published. Get the word out on <a href='/lists'>the discussion lists</a>!"
end
redirect_to @node.path
if params[:redirect] && params[:redirect] == 'question'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this here, can we do it inside the @node.path method, which we already use to switch between types? I think we should be able to based on whether there are tags on the note, since they'll have been added by this point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes we can surely do that by changing the path for questions in the generate_path in the drupal_node model method. But that would mean users could no longer view the as normal research notes. Thus it would affect the present case if deployed on the main website, thus affecting the backward compatibility. So I devised a way so that question could co-exist in the research notes page as well as in the questions page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! Great to know this was considered. I'm interested in how this can be clearly communicated in how the code is implemented, and also keep path generation code centralized.

Do you think we could have @node.path() accept an optional parameter, like def path(type = :default) (best double check that for setting defaults as :symbols but I think it'd work) where using @node.path(:question) would generate the question version of the path? That also reduced redundancy in this controller.

redirect_to '/questions/'+@node.author.name+'/'+Time.at(@node.created).strftime("%m-%d-%Y")+'/'+@node.title.parameterize
else
redirect_to @node.path
end
else
render :template => "editor/post"
end
Expand Down Expand Up @@ -159,7 +163,11 @@ def update
end
@node.save!
flash[:notice] = "Edits saved."
redirect_to @node.path
if params[:redirect] && params[:redirect] == 'question'
redirect_to '/questions/'+@node.author.name+'/'+Time.at(@node.created).strftime("%m-%d-%Y")+'/'+@node.title.parameterize
else
redirect_to @node.path
end
else
flash[:error] = "Your edit could not be saved."
render :action => :edit
Expand Down
82 changes: 82 additions & 0 deletions app/controllers/questions_controller.rb
@@ -0,0 +1,82 @@
class QuestionsController < ApplicationController

def index
@title = "Recent Questions"
@notes = DrupalNode.where(status: 1, type: 'note')
.joins(:drupal_tag)
.where('term_data.name LIKE ?', 'question:%')
.order('node.nid DESC')
.paginate(:page => params[:page], :per_page => 30)
@wikis = DrupalNode.limit(10)
.where(type: 'page', status: 1)
.order("nid DESC")
end

def show
if params[:author] && params[:date]
@node = DrupalNode.where(path: "/notes/#{params[:author]}/#{params[:date]}/#{params[:id]}").first
@node = @node || DrupalNode.where(path: "/report/#{params[:id]}").first
else
@node = DrupalNode.find params[:id]
end

unless @node.has_power_tag('question')
flash[:error] = "Not a question"
redirect_to "/"
end

if @node.author.status == 0 && !(current_user && (current_user.role == "admin" || current_user.role == "moderator"))
flash[:error] = "The author of that note has been banned."
redirect_to "/"
elsif @node.status == 4 && (current_user && (current_user.role == "admin" || current_user.role == "moderator"))
flash[:warning] = "First-time poster <a href='#{@node.author.name}'>#{@node.author.name}</a> submitted this #{time_ago_in_words(@node.created_at)} ago and it has not yet been approved by a moderator. <a class='btn btn-default btn-sm' href='/moderate/publish/#{@node.id}'>Approve</a> <a class='btn btn-default btn-sm' href='/moderate/spam/#{@node.id}'>Spam</a>"
elsif @node.status == 4 && (current_user && current_user.id == @node.author.id) && !flash[:first_time_post]
flash[:warning] = "Thank you for contributing open research, and thanks for your patience while your post is approved by <a href='/wiki/moderation'>community moderators</a> and we'll email you when it is published. In the meantime, if you have more to contribute, feel free to do so."
elsif @node.status != 1 && !(current_user && (current_user.role == "admin" || current_user.role == "moderator"))
# if it's spam or a draft
# no notification; don't let people easily fish for existing draft titles; we should try to 404 it
redirect_to "/"
end

@node.view
@title = @node.latest.title
@tags = @node.tags
@tagnames = @tags.collect(&:name)

set_sidebar :tags, @tagnames
end

def shortlink
@node = DrupalNode.find params[:id]
redirect_to '/questions/'+@node.author.name+'/'+Time.at(@node.created).strftime("%m-%d-%Y")+'/'+@node.title.parameterize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use @node.path here too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helps centralize where paths are generated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar answer as the previous thread.

end

def popular
@title = "Popular Questions"
@notes = DrupalNode.where(status: 1, type: 'note')
.joins(:drupal_tag)
.where('term_data.name LIKE ?', 'question:%')
.order('node_counter.totalcount DESC')
.includes(:drupal_node_counter)
.limit(20)
@wikis = DrupalNode.limit(10)
.where(type: 'page', status: 1)
.order("nid DESC")
@unpaginated = true
render :template => 'questions/index'
end

def liked
@title = "Highly liked Questions"
@notes = DrupalNode.where(status: 1, type: 'note')
.joins(:drupal_tag)
.where('term_data.name LIKE ?', 'question:%')
.order("cached_likes DESC")
.limit(20)
@wikis = DrupalNode.limit(10)
.where(type: 'page', status: 1)
.order("nid DESC")
@unpaginated = true
render :template => 'questions/index'
end
end
6 changes: 4 additions & 2 deletions app/controllers/user_sessions_controller.rb
Expand Up @@ -32,8 +32,10 @@ def create
return_to = session[:openid_return_to]
session[:openid_return_to] = nil
redirect_to return_to
elsif params[:return_to]
redirect_to params[:return_to]
elsif session[:return_to]
return_to = session[:return_to]
session[:return_to] = nil
redirect_to return_to
else
redirect_to "/dashboard"
end
Expand Down
4 changes: 4 additions & 0 deletions app/views/editor/post.html.erb
Expand Up @@ -79,6 +79,10 @@
<h3>Share your work</h3>
<% end %>

<% if params[:redirect] == 'question' %>
<%= hidden_field_tag 'redirect', 'question' %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we instead simply rely on the provided tagging?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added to provide redirect to the question show path only when a :redirect parameter is given in the url. Well I thought of redirecting the questions to the notes show page if questions are posted from post a research note link so that the user doesn't gets redirected to the questions show page which is currently under construction.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see -- so this is temporary? If so, let's leave a clear comment that it should be removed once question show template is complete. Something like <!-- Notice: Remove this ... -->. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will add comments wherever necessary.

<% end %>

<div class="form-group">
<input id="title" tabindex="1" name="title" class="form-control" placeholder="Title" value="<%= if @node then @node.title else params[:title] end %><%= "Question: " if params[:template] == "question" %><%= 'Public Lab Community Newsletter '+ DateTime.now.to_date.to_s(:long) if params[:newsletter] %>"/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/like/_like.html.erb
Expand Up @@ -33,7 +33,7 @@
<hr />

<div class='btn-group'>
<% if node.type == 'note' %><a <% if current_user && current_user.uid != node.uid %>data-confirm='Please be aware that you are editing someone else\'s post, a privilege you have only because you are a moderator or admin.' <% end %>class='btn btn-default btn-sm' href='/notes/edit/<%= node.id %>?t=<%= Time.now.to_i %>'><i class='fa fa-pencil'></i><span class='hidden-xs hidden-sm'> Edit</span></a><% end %>
<% if node.type == 'note' %><a <% if current_user && current_user.uid != node.uid %>data-confirm='Please be aware that you are editing someone else\'s post, a privilege you have only because you are a moderator or admin.' <% end %>class='btn btn-default btn-sm' href='/notes/edit/<%= node.id %>?t=<%= Time.now.to_i %><% if params[:controller] == "questions" %>&redirect=question<% end %>'><i class='fa fa-pencil'></i><span class='hidden-xs hidden-sm'> Edit</span></a><% end %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do this at the controller level, as it's relatively hidden here. Can we check for tagging at the controller and redirect there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar answer as the last thread. Done so that user is not redirected to the questions show page while editing from the notes show page.

<a href='/notes/delete/<%= node.id %>' class='btn btn-default btn-sm' data-confirm='Are you sure?'>
<i class='fa fa-trash'></i><span class='hidden-xs hidden-sm' Delete</span>
</a>
Expand Down
8 changes: 8 additions & 0 deletions app/views/notes/_format_toggle.html.erb
Expand Up @@ -7,7 +7,11 @@
(function(){
toggle_format = function(format) {
if (format == "grid") {
<% if params[:controller] == 'questions' %>
$('.note').addClass('col-md-4')
<% else %>
$('.note').addClass('col-md-3')
<% end %>
$('.note .img-thumbnail').css('width','100%')
$('.note hr.bottom').hide()
$('#notes hr.hidden-sm').show()
Expand All @@ -16,7 +20,11 @@
$('#notes._container-fluid').addClass('container-fluid')
$('#notes._container-fluid').removeClass('_container-fluid')
} else {
<% if params[:controller] == 'questions' %>
$('.note').removeClass('col-md-4')
<% else %>
$('.note').removeClass('col-md-3')
<% end %>
$('.note .img-thumbnail').css('width','30%')
$('.note hr.bottom').show()
$('#notes hr.hidden-sm').hide()
Expand Down
2 changes: 1 addition & 1 deletion app/views/notes/show.html.erb
Expand Up @@ -16,7 +16,7 @@
<%= render :partial => "like/like", :locals => {:node => @node, :tagnames => @tagnames } %>
</div>

<h1 style="margin-top: 30px;font-family: 'Junction Light';clear:left;"><% if @node.has_power_tag('question') %><span style="color:#aaa;font-style:italic;"><i class="fa fa-question-sign"></i> Question:</span> <% end %><%= @node.title %></h1>
<h1 style="margin-top: 40px;"><% if @node.has_power_tag('question') %><span class="question">Question:</span> <% end %><%= @node.title %></h1>

<% if @node.has_power_tag('question') %>
<% pt = @node.power_tag('question') %>
Expand Down
53 changes: 53 additions & 0 deletions app/views/questions/index.html.erb
@@ -0,0 +1,53 @@
<%= render :partial => "sidebar/user" %>
<% if params[:action] == 'popular' %>
<h2>Popular Questions <small class="hidden-sm">Most viewed questions</small></h2>
<% elsif params[:action] == 'liked' %>
<h2>Liked Questions <small class="hidden-sm">Most liked questions</small></h2>
<% else %>
<h2>All Questions <small class="hidden-sm">Listing all recent questions</small></h2>
<% end %>
<div class="col-md-9">
<%= render :partial => "notes/format_toggle" %>
<ul class="nav nav-tabs">
<li<% if params[:action] == "index" %> class="active"<% end %>><a href="/questions/">Recent</a></li>
<li<% if params[:action] == "popular" %> class="active"<% end %>><a href="/questions/popular/">Popular</a></li>
<li<% if params[:action] == "liked" %> class="active"<% end %>><a href="/questions/liked/"><i class="fa fa-star-o"></i><span class="hidden-sm"> Liked</span></a></li>
</ul>
<div id="notes">
<div class="row">
<% @notes.each_with_index do |node,i| %>
<div class="<% if @widget %>col-xs-4 col-sm-4 <% end %>col-md-4 note note-container-question" style="margin-top:20px;">
<div class="note-pane note-question<% if node.status == 4 %> moderated<% end %>">

<div class="header-icon"><i class="fa fa-question-circle"></i></div>

<%= render partial: 'dashboard/node_moderate', locals: { node: node } %>

<h4><a <% if @widget %>target="_blank"<% end %> href="/questions/<%= node.author.name %>/<%= Time.at(node.created).strftime("%m-%d-%Y") %>/<%= node.title.parameterize %>"><%= node.title %></a></h4>

<p class="meta">asked <%= render partial: "dashboard/node_meta", locals: { node: node } %></p>

<span id="tags">
<% node.tags.limit(4).each do |tag| %>
<span id="tag_<%= tag.id %>" class="label label-primary"><a href="/tag/<%= tag.name %>"><%= tag.name %></a></span>
<% end %>
</span>
<p style="margin-top:30px;"><% if logged_in_as(['admin','moderator']) %><a class="btn btn-default btn-xs" href="/moderate/spam/<%= node.id %>"><i class="fa fa-ban"></i> Spam</a><% end %>
<a href="#" class="btn btn-default btn-xs">Post an answer</a></p>
</div>
</div>

<% unless @widget %><hr class="visible-xs visible-sm" /><% end %>
<% if ((i+1)/3.0).to_i == ((i+1)/3.0) %>
</div>
<% unless @widget %><hr class="visible-xs visible-sm grid" /><% end %>
<div class="row">
<% end %>
<% end %>
</div>
</div>
</div>
<div class="text-center"><%= will_paginate @notes, :renderer => BootstrapPagination::Rails unless @unpaginated %></div>

<%= stylesheet_link_tag "dashboard" %>
<%= javascript_include_tag "dashboard" %>
42 changes: 42 additions & 0 deletions app/views/questions/show.html.erb
@@ -0,0 +1,42 @@
<%= render :partial => "sidebar/related" %>
<div class="col-md-9 note-show">

<div style="margin-top:10px;" class="hidden-print">
<%= render :partial => "like/like", :locals => {:node => @node, :tagnames => @tagnames } %>
</div>

<h1 style="margin-top: 40px;"><span class="question">Question:</span><a href="/questions/<%= @node.author.name %>/<%= Time.at(@node.created).strftime("%m-%d-%Y") %>/<%= @node.title.parameterize %>"><%= @node.title %></a></h1>
<% pt = @node.power_tag('question') %>
<div class="alert alert-warning">
<a href="/profile/<%= @node.author.name %>"> <%= @node.author.name %> </a>
is asking a question about <b><%= pt %></b>:
<a class="btn btn-default" target="_blank" href="/subscribe/tag/question:<%= pt %>">
Subscribe to answer questions on this topic
</a>
</div>
<div class="inline">
<% if @node.author.user && @node.author.user.photo_file_name %>
<img class="img-circle" src="<%= @node.author.user.photo_path(:thumb) %>" />
<% else %>
<div class="img-circle"></div>
<% end %>
</div>
<div class="inline">
<p><a href="/profile/<%= @node.author.name %>"><%= @node.author.name %></a> asked on <%= @node.created_at.to_s(:long) %> <% if @node.status == 0 || @node.status == 4 %><span class="label label-danger">| UNPUBLISHED</span><% end %> <br />
<small><i class="fa fa-eye"></i> <%= number_with_delimiter(@node.totalcount) %> <span class="hidden-xs hidden-sm hidden-print ">views</span> | <a href="/q/<%= @node.id %>">shortlink</a></small></p>
</div>

<hr style="margin-top:10px;" />

<div style="overflow:hidden;" id="content">
<%= raw auto_link(@node.latest.render_body, :sanitize => false) %>
</div>

<hr />

<%= render :partial => "home/social" %>

<hr />

<%= render :partial => "tag/tagging" %>
</div>
12 changes: 12 additions & 0 deletions app/views/sidebar/_post_button.html.erb
@@ -1,10 +1,22 @@
<% if params[:controller] == 'questions' %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep this template file simpler. Can we put this question button at the top of the questions index page?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok Jeff I will add the Ask a question button at the top of the question show page and index page.

<a style="margin-bottom:6px;" rel="tooltip" title="Ask a question to the community" data-placement="bottom" href="/post?tags=question:question&template=question&redirect=question" class="btn btn-primary btn-lg btn-block hidden-md"><i class="fa fa-question-circle fa-white"></i> Ask a Question</a>
<% else %>
<a style="margin-bottom:6px;" rel="tooltip" title="Share your work with others" data-placement="bottom" href="/post" class="btn btn-primary btn-lg btn-block hidden-md"><i class="fa fa-pencil fa-white"></i> Write a research note</a>
<% end%>
<div class="btn-group visible-md" style="margin-bottom:6px;">
<% if params[:controller] == 'questions' %>
<a rel="tooltip" title="Ask a question to the community" data-placement="bottom" href="/post?tags=question:question&template=question&redirect=question" class="btn btn-primary btn-lg"><i class="fa fa-question-circle fa-white"></i> Ask Question</a>
<% else %>
<a rel="tooltip" title="Share your work with others" data-placement="bottom" href="/post" class="btn btn-primary btn-lg"><i class="fa fa-pencil fa fa-white"></i> Post research</a>
<% end %>
<a class="btn btn-primary btn-lg dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>

<ul class="dropdown-menu">
<% if params[:controller] == 'questions' %>
<li><a href="/post?tags=question:question&template=question&redirect=question"><i class="fa fa-question-circle"></i> <b>Ask a Question</b></a></li>
<% else %>
<li><a href="/post"><i class="fa fa-pencil"></i> <b>Post a research note</b></a></li>
<% end %>
<li><a href="/wiki/new"><i class="fa fa-book"></i> Create a wiki page</a></li>
<li class="divider"></li>
<li><a href="/wiki/about-posting" class="hidden-lg"><i class="fa fa-question-sign"></i> About posting</a></li>
Expand Down
5 changes: 5 additions & 0 deletions app/views/sidebar/_related.html.erb
Expand Up @@ -16,7 +16,12 @@

<div id="sidebar" class="hidden-xs hidden-sm">

<% if params[:controller] == 'questions' %>
<a style="margin-bottom:6px;" rel="tooltip" title="Ask a quuestion to the community" data-placement="bottom" href="/post?tags=question:question&template=question&redirect=question" class="btn btn-primary btn-lg btn-block hidden-sm"><i class="fa fa-question-circle fa fa-white"></i> Ask a Question</a>
<% else %>
<a style="margin-bottom:6px;" rel="tooltip" title="Share your work with others" data-placement="bottom" href="/post" class="btn btn-primary btn-lg btn-block hidden-sm"><i class="fa fa-pencil fa fa-white"></i> Write a research note</a>
<% end %>

<a rel="tooltip" title="Post <% if @tagnames %>about <%= (@tagnames.uniq.delete_if{|x| x.match(":") }).join(',') %><% else %>research<% end %>" data-placement="bottom" href="/post<%= '?tags='+(@tagnames.uniq.delete_if{|x| x.match(":") }).join(',') if @tagnames %><% if params[:controller] == 'notes' && params[:action] == 'show' %>,response:<%= @node.id %><% end %>" class="btn btn-primary btn-lg btn-block"><i class="fa fa-pencil fa fa-white"></i> Post related work &raquo;</a>

<% if @node %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tag/_tagging.html.erb
@@ -1,7 +1,7 @@
<p>
<span id="tags">
<% @node.tags.each do |tag| %>
<span id="tag_<%= tag.id %>" class="label label-primary" style="font-size:13px;margin-right:4px;">
<span id="tag_<%= tag.id %>" class="label label-primary">
<a href="<%= "/maps" if @node.type == "map" %>/tag/<%= tag.name %>"><%= tag.name %></a>
<% if current_user && (tag.is_community_tag(@node.id) && tag.belongs_to(current_user,@node.id) || current_user.role == "admin" || current_user.role == "moderator") %>
<a class="tagdelete" data-remote="true" href="/tag/delete/<%= @node.id %>/<%= tag.id %>">x</a>
Expand Down
8 changes: 8 additions & 0 deletions config/routes.rb
@@ -1,4 +1,5 @@
Plots2::Application.routes.draw do

resources :rusers
resources :user_sessions
resources :images
Expand Down Expand Up @@ -190,6 +191,13 @@

match 'talk/:id' => 'talk#show'

match 'questions' => 'questions#index'
match 'questions/:author/:date/:id' => 'questions#show'
match 'questions/show/:id' => 'questions#show'
match 'q/:id' => 'questions#shortlink'
match 'questions/popular' => 'questions#popular'
match 'questions/liked' => 'questions#liked'

# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products

Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/community_tags.yml
Expand Up @@ -27,3 +27,9 @@ chapter:
uid: 1
nid: 7
date: Time.now

question:
tid: 6
uid: 2
nid: 8
date: Time.now