Order the vocabs

This commit is contained in:
Bernie Chiu 2013-08-25 18:11:19 +08:00 committed by chris
parent 28a8880862
commit ab29dd4335
2 changed files with 10 additions and 9 deletions

View File

@ -28,7 +28,7 @@ class Panel::Dictionary::FrontEnd::DictionaryVocabsController < OrbitWidgetContr
end end
if params[:search_query].empty? if params[:search_query].empty?
@vocabs = DictionaryVocab.page(params[:page_main]).per(@page_num) @vocabs = DictionaryVocab.desc(:created_at).page(params[:page_main]).per(@page_num)
else else
@vocabs = DictionaryVocab.solr_search do @vocabs = DictionaryVocab.solr_search do
fulltext params[:search_query] fulltext params[:search_query]

View File

@ -15,18 +15,19 @@
<tr> <tr>
<td><%= vocab.dictionary_vocab_category.title %></td> <td><%= vocab.dictionary_vocab_category.title %></td>
<td><%= link_to truncate(vocab.word,length: 25), panel_dictionary_front_end_dictionary_vocab_path(vocab) %></td> <td><%= link_to truncate(vocab.word,length: 25), panel_dictionary_front_end_dictionary_vocab_path(vocab) %></td>
<td><% if vocab.created_at > Time.now.beginning_of_day %> <td>
<%="#{time_ago_in_words(vocab.created_at)}"%> <% if vocab.created_at > Time.now.beginning_of_day %>
<%=t :ago,:scope => :dictionary%> <%="#{time_ago_in_words(vocab.created_at)}"%>
<% else %> <%=t :ago,:scope => :dictionary%>
<%= vocab.created_at.strftime("%Y/%m/%d") %> <% else %>
<% end %></td> <%= vocab.created_at.strftime("%Y/%m/%d") %>
<% end %>
</td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
<%= paginate( @vocabs, :param_name => :page_main, :params => {:inner => 'false'} ) rescue nil %> <%= paginate(@vocabs, :param_name => :page_main, :params => {:inner => 'false'} ) rescue nil %>