Skip to content

Instantly share code, notes, and snippets.

View boblmartens's full-sized avatar

Bob Martens boblmartens

View GitHub Profile
##
# Calendar helper with proper events
# http://www.cuppadev.co.uk/webdev/making-a-real-calendar-in-rails/
#
# (C) 2009 James S Urquhart (jamesu at gmail dot com)
# Derived from calendar_helper
# (C) Jeremy Voorhis, Geoffrey Grosenbach, Jarkko Laine, Tom Armitage, Bryan Larsen
# Licensed under MIT. http://www.opensource.org/licenses/mit-license.php
##
<% render :partial => "comments/add_comment", :object => @comment = Comment.new, :locals => { :button_name => 'post comment' } %>
<h2>Welcome to Jibber!</h2>
<% if @posts.size == 0 %>
<p>I'm sorry, you need to write a post.</p>
<% else %>
<% @posts.each do |post| %>
<div class="indexPostContainer">
<h3><%= link_to post.title, post %></h3>
<h4>Posted by <%= post.user.name %> at <%= post.created_at %></h4>
<h5>Tags: <%= post.tag_list %></h5>
<%= markdown post.body %>
<h2>Welcome to Jibber!</h2>
<% if @posts.size == 0 %>
<p>I'm sorry, you need to write a post.</p>
<% else %>
<%= render :partial => @posts %>
<% end %>
@boblmartens
boblmartens / user.rb
Created November 25, 2008 01:31
a possible password system
attr_accessor :new_password
validates_presence_of :new_password, :on => :create
validates_length_of :new_password, :minimum => 6, :allow_nil => true, :allow_blank => true, :unless => :new_password.blank?
validates_confirmation_of :new_password
before_save :set_encrypted_password
def set_encrypted_password
write_attribute(:password, Client.encrypt_password(@new_password)) unless @new_password.nil? || @new_password.blank?