Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add fields to events.

  • Loading branch information...
commit f6c115f068c96655848d0b3bc5d8b0c3e3af2bcc 1 parent 0ec079c
Mike Tierney authored March 26, 2013
3  app/models/event.rb
... ...
@@ -1,3 +1,4 @@
1 1
 class Event < ActiveRecord::Base
2  
-  # attr_accessible :title, :body
  2
+  default_scope order('event_date DESC')
  3
+  attr_accessible :event_date, :title, :summary, :description, :details, :speaker_id
3 4
 end
35  app/views/events/index.html.erb
... ...
@@ -1,21 +1,18 @@
1  
-<h1>Listing events</h1>
2  
-
3  
-<table>
4  
-  <tr>
5  
-    <th></th>
6  
-    <th></th>
7  
-    <th></th>
8  
-  </tr>
9  
-
10  
-<% @events.each do |event| %>
11  
-  <tr>
12  
-    <td><%= link_to 'Show', event %></td>
13  
-    <td><%= link_to 'Edit', edit_event_path(event) %></td>
14  
-    <td><%= link_to 'Destroy', event, method: :delete, data: { confirm: 'Are you sure?' } %></td>
15  
-  </tr>
  1
+<% content_for :title do %>
  2
+Events
16 3
 <% end %>
17  
-</table>
  4
+<div class="row">
  5
+  <h1 class="large-12 columns">Events</h1>
  6
+</div>
18 7
 
19  
-<br />
20  
-
21  
-<%= link_to 'New Event', new_event_path %>
  8
+<% @events.each do |event| %>
  9
+<div class="row">
  10
+  <div class="large-2 columns">
  11
+    <%= event.event_date %> 
  12
+  </div>
  13
+  <div class="large-10 columns">
  14
+    <h2><%= link_to event.title, event_path(event) %></h2>
  15
+    <p><%= raw event.summary %></p>
  16
+  </div>
  17
+</div>
  18
+<% end %>
2  app/views/layouts/application.html.erb
@@ -16,7 +16,7 @@
16 16
 <html lang="en">
17 17
 <[endif]-->
18 18
   <head>
19  
-    <title><%= content_for?(:title) ? yield(:yield) : 'Untitled' %></title>
  19
+    <title><%= content_for?(:title) ? "#{yield(:title)} | " : '' %>Refresh Seattle</title>
20 20
 
21 21
     <meta charset="utf-8" />
22 22
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10  db/migrate/20130327025740_add_fields_to_events.rb
... ...
@@ -0,0 +1,10 @@
  1
+class AddFieldsToEvents < ActiveRecord::Migration
  2
+  def change
  3
+    add_column :events, :event_date, :datetime
  4
+    add_column :events, :title, :string
  5
+    add_column :events, :summary, :text
  6
+    add_column :events, :description, :text
  7
+    add_column :events, :details, :text
  8
+    add_column :events, :speaker_id, :integer
  9
+  end
  10
+end
12  db/schema.rb
@@ -11,11 +11,17 @@
11 11
 #
12 12
 # It's strongly recommended to check this file into your version control system.
13 13
 
14  
-ActiveRecord::Schema.define(:version => 20130226174716) do
  14
+ActiveRecord::Schema.define(:version => 20130327025740) do
15 15
 
16 16
   create_table "events", :force => true do |t|
17  
-    t.datetime "created_at", :null => false
18  
-    t.datetime "updated_at", :null => false
  17
+    t.datetime "created_at",  :null => false
  18
+    t.datetime "updated_at",  :null => false
  19
+    t.datetime "event_date"
  20
+    t.string   "title"
  21
+    t.text     "summary"
  22
+    t.text     "description"
  23
+    t.text     "details"
  24
+    t.integer  "speaker_id"
19 25
   end
20 26
 
21 27
   create_table "speakers", :force => true do |t|

0 notes on commit f6c115f

Please sign in to comment.
Something went wrong with that request. Please try again.