Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Persist shouts

  • Loading branch information...
commit 8d814c82cb9676cd1dfab50172412398627e455c 1 parent 9f654eb
@halogenandtoast authored
View
4 app/controllers/dashboards_controller.rb
@@ -1,3 +1,5 @@
class DashboardsController < ApplicationController
-
+ def show
+ @shout = Shout.new
+ end
end
View
7 app/controllers/shouts_controller.rb
@@ -0,0 +1,7 @@
+class ShoutsController < ApplicationController
+ def create
+ @shout = current_user.shouts.new(params[:shout])
+ @shout.save
+ redirect_to dashboard_path
+ end
+end
View
1  app/models/user.rb
@@ -1,3 +1,4 @@
class User < ActiveRecord::Base
include Clearance::User
+ has_many :shouts
end
View
5 app/views/dashboards/show.html.erb
@@ -1 +1,6 @@
Welcome <%= current_user.email %>
+
+<%= form_for(@shout) do |form| %>
+ <%= form.text_field :body, placeholder: "Shout here" %>
+ <%= form.submit "Shout!" %>
+<% end %>
View
1  config/routes.rb
@@ -1,4 +1,5 @@
Shouter::Application.routes.draw do
root to: "welcome#index"
resource :dashboard, only: [:show]
+ resources :shouts, only: [:create]
end
Please sign in to comment.
Something went wrong with that request. Please try again.