Skip to content

Instantly share code, notes, and snippets.

View baileylo's full-sized avatar

Logan Bailey baileylo

View GitHub Profile
<%= form_for(@conversation) do |f| %>
<% if @conversation.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@conversation.errors.count, "error") %> prohibited this conversation from being saved:</h2>
<ul>
<% @conversation.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
@baileylo
baileylo / create_boards.rb
Created October 15, 2010 06:48
Modify migration files to add indexes and some database constraints on input size
class CreateBoards < ActiveRecord::Migration
def self.up
create_table :boards do |t|
t.integer :id
t.string :title, :limit => 50
t.timestamps
end
end
@baileylo
baileylo / board.rb
Created October 15, 2010 06:56
Modifying applications models so they're aware of eachother
class Board < ActiveRecord::Base
has_many :conversations
end
@baileylo
baileylo / routes.rb
Created October 15, 2010 07:19
Modifying routes
LoginApp::Application.routes.draw do
resources :boards do
resources :conversations
end
root :to => "boards#index"
resources :users, :user_sessions
match 'login' => 'user_sessions#new', :as => :login
@baileylo
baileylo / layout.html.erb
Created October 15, 2010 07:27
Adding some basic styling
<!DOCTYPE html>
<html>
<head>
<title>Rails Message Boards</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
<body>
@baileylo
baileylo / style.css
Created October 15, 2010 07:29
basic global styles
/* Layout Styles */
#wrapper {
width: 750px;
margin: 25px auto;
border: 1px solid black;
}
#top_nav {
padding: 5px;
text-align: right;
@baileylo
baileylo / index.html.erb
Created October 15, 2010 07:38
New board index layout
<h1 id="page_title">Message Boards</h1>
<p id="notice"><%= notice %></p>
<table>
<tr>
<th align="left">Title</th>
</tr>
<% @boards.each do |board| %>
<tr>
<td><%= link_to board.title, board %></td>
@baileylo
baileylo / shows.html.erb
Created October 15, 2010 07:43
Trying to add some usable content.
<h1 id="page_title"><%= @board.title %></h1>
<p id="notice"><%= notice %></p>
<%= link_to 'Rails Boards', boards_path %> &gt; <%= link_to @board.title, @board %> <br />
<%= link_to 'Post New Message', new_board_conversation_url(@board) %>
@baileylo
baileylo / conversation.rb
Created October 15, 2010 07:51
Make sure we're looking at board
class ConversationsController < ApplicationController
before_filter :load_board
# GET /conversations
# GET /conversations.xml
def index
@conversations = Conversation.all
respond_to do |format|
format.html # index.html.erb
@baileylo
baileylo / shows.html.erb
Created October 19, 2010 07:36
Updates to the board show to display conversations in the board
<h1 id="page_title"><%= @board.title %></h1>
<p id="notice"><%= notice %></p>
<%= link_to 'Rails Boards', boards_path %> &gt; <%= link_to @board.title, @board %> <br />
<table>
<tr>
<th>Post / Author</th>
<th>Last Reply</th>
<th>Number of Replies</th>
</tr>