Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2011 04:26
Show Gist options
  • Save anonymous/852330 to your computer and use it in GitHub Desktop.
Save anonymous/852330 to your computer and use it in GitHub Desktop.
Sequel Column Aliases & Virtual Attributes
<%
BlogPost.select(:headline, 'substring(body from "^.*?</p>")'.as(:body_preview)).
order(:post_date.desc).all do |post|
%>
<div>
<h2><%=post.headline%></h2>
<%==post.body_preview%>
</div>
<% end %>
class BlogPost < Sequel::Model(:blog__posts)
attr_accessor :body_preview
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment