Permalink
Browse files

added the shout show

  • Loading branch information...
1 parent 9a6033c commit e0618a9e0f6886ffd196295e8f56374b216a5826 @drapergeek committed Mar 12, 2012
@@ -1,6 +1,12 @@
class ShoutsController < ApplicationController
+
+ def show
+ @shout = Shout.find(params[:id])
+ end
+
def create
@shout = current_user.shouts.create!(params[:shout])
redirect_to dashboard_path, notice: "Shouted!"
end
+
end
View
@@ -1,6 +1,8 @@
class Shout < ActiveRecord::Base
belongs_to :user
+ delegate :email, :to=>:user, :prefix=>true
+
def self.current
order("created_at DESC")
end
@@ -1,3 +1,3 @@
<%= content_tag_for(:div, shout) do %>
- <%= shout.body %> - <%= time_ago_in_words(shout.created_at) %> ago
+ <%= link_to shout.body, shout %> - <%= time_ago_in_words(shout.created_at) %> ago
<% end %>
@@ -0,0 +1,8 @@
+<h2>Shout from <%= @shout.user_email %></h2>
+<div>
+ <strong><%= @shout.body %></strong>
+ <small><%= time_ago_in_words(@shout.created_at) %> ago</small>
+</div>
+<div>
+ <%= link_to "Dashboard", dashboard_path %>
+</div>
View
@@ -1,5 +1,5 @@
Shouter::Application.routes.draw do
resource :dashboard, only: [:show]
- resources :shouts, only: [:create]
+ resources :shouts, only: [:show, :create]
root to: "welcome#index"
end

0 comments on commit e0618a9

Please sign in to comment.