Skip to content

Instantly share code, notes, and snippets.

View overture8's full-sized avatar

Phil McClure overture8

  • Stora
  • Belfast, Northern Ireland
View GitHub Profile
// ***** Roast Theme
!base_color_1 = #2D1E1E
!base_color_2 = #4B3C37
!base_color_1_light = !base_color_1 + #212121
!base_color_1_lighter = !base_color_1 + #444444
!base_color_1_dark = !base_color_1 - #111111
!base_color_2_light = !base_color_2 + #212121
!base_color_2_lighter = !base_color_2 + #444444
// ***** Ruby Theme
!base_color_1 = #212121
!base_color_2 = #660000
!base_color_1_light = !base_color_1 + #212121
!base_color_1_lighter = !base_color_1 + #444444
!base_color_1_dark = !base_color_1 - #111111
!base_color_2_light = !base_color_2 + #212121
!base_color_2_lighter = !base_color_2 + #444444
@overture8
overture8 / sort_mongomapper_embeddoc.rb
Created January 20, 2010 11:46
How to sort by a field in an EmbeddedDcouemt (MongoMapper)
post.comments.sort_by(&:created_at)
@overture8
overture8 / mongomapper_sort_desc.rb
Created January 20, 2010 11:47
Sort field in MongoMapper EmbeddedDocument (Descending)
post.comments.sort_by(&:created_at).reverse
<div id="comments">
<%= render @post.comments %>
</div>
<% form_for [@post, Comment.new], :remote => true do |f| %>
<%= f.label :body %><br />
<%= f.text_area :body, :rows => 5 %><br />
<%= f.submit %>
<% end %>
$('comments').insert( { bottom: "<%= escape_javascript(render @comment) %>" } ); // Insert the _comment partial at the bottom of the comments list
$$('.comment').last().highlight(); // Highlight the last comment (the one you just inserted!)
$('comment_body').clear(); // Clear the form text area
class CommentsController < ApplicationController
respond_to :html, :xml, :js
def create
post = Post.find(params[:post_id])
@comment = post.comments.build(params[:comment])
if @comment.save
respond_with(@comment)
end
end
# Middleware
use Rack::Codehighlighter, :coderay, :element => "pre", :pattern => /\A:::(\w+)\s*\n/
require ::File.expand_path('../config/environment', __FILE__)
run Test3app::Application
class Application < Rails::Application
config.middleware.use Rack::Codehighlighter, :coderay, :element => "pre", :pattern => /\A:::(\w+)\s*\n/
.
.
.
end