Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,9 @@ def published_notes
.where('node.status = 1')
.where.not(nid: hidden_nids)
end
def random

Choose a reason for hiding this comment

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

Use empty lines between method definitions.

post = Post.order("RANDOM()").first
redirect_to post_path(post)
end

end
17 changes: 11 additions & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,17 @@
<%= render :partial => 'layouts/header' %>
<div id="top_map"> </div>
<div class="container">
<div class="row">

<%= yield %>

</div><!--/row-->
</div><!--/container-->
<div class="row">

<div class="col-md-12 mb-2">
<%= link_to '🎲 Random Post', random_path, class: 'btn btn-secondary' %>
</div>

<%= yield %>

</div><!--/row-->
</div><!--/container-->


<%= render :partial => "layouts/footer" %>

Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

# Manually written API functions
post 'comment/create/token/:id.:format', to: 'comment#create_by_token'
get '/random', to: 'posts#random'


post '/node/update/title' => 'notes#update_title'

Expand Down
Loading