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 AddSlugToArticles < ActiveRecord::Migration | |
def change | |
add_column :articles, :slug, :string | |
add_index :articles, :slug | |
end | |
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
<h2>Recent Articles</h2> | |
<table class="table table-bordered"> | |
<% @articles.each do |article| %> | |
<tr> | |
<td><%= link_to article.title, article %></td> | |
</tr> | |
<tr> | |
<td><em>Posted: <%= article.created_at.strftime('%a %d %B %Y - %H:%M') %></em></td> | |
</tr> | |
<% 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
<h2>Recent Drafts</h2> | |
<table class="table table-bordered"> | |
<% @articles.each do |article| %> | |
<tr> | |
<td><%= article.title %></td> | |
</tr> | |
<tr> | |
<td><em>Posted: <%= article.created_at.strftime('%a %d %B %Y - %H:%M') %></em></td> | |
</tr> | |
<tr> |
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
<h1><%=@count%> Notes (<%[email protected]%>)</h1> | |
<% unless @notes.nil? %> | |
<ul> | |
<% @notes.each do |note| %> | |
<li><a href="/note/<%= note.id %>"><%= note.title %></a> </li> | |
<% end %> | |
</ul> | |
<%= will_paginate @notes %> | |
<% else %> |
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
get '/notes/:category' do | |
@notes = Note.all.paginate(:category_id => params[:category],:page => params[:page], :per_page => 10) | |
@cat = Category.get(params[:category]) | |
erb :notes | |
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
<h2>Notes Categories</h2> | |
<% unless @categories.nil? %> | |
<ul> | |
<% @categories.each do |category| %> | |
<li><a href="/notes/<%= category.id %>"><%= category.name %></a></li> | |
<% end %> | |
</ul> | |
<% else %> | |
<p>No notes categories at the moment :-(</p> |
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 Category | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String | |
has n, :notes | |
end | |
class Note |
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
get '/' do | |
@categories = Category.all(:order => [ :id.asc ]) | |
erb :home | |
end |