Skip to content

Commit

Permalink
added the shout show
Browse files Browse the repository at this point in the history
  • Loading branch information
drapergeek committed Mar 12, 2012
1 parent 9a6033c commit e0618a9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/controllers/shouts_controller.rb
@@ -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
2 changes: 2 additions & 0 deletions app/models/shout.rb
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/shouts/_shout.html.erb
@@ -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 %>
8 changes: 8 additions & 0 deletions app/views/shouts/show.html.erb
@@ -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>
2 changes: 1 addition & 1 deletion config/routes.rb
@@ -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.