Created
March 3, 2011 04:26
-
-
Save anonymous/852330 to your computer and use it in GitHub Desktop.
Sequel Column Aliases & Virtual Attributes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
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 %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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