Permalink
Browse files

TextShout form

  • Loading branch information...
1 parent d1ddefe commit 03aa2ca9785bc439ba386f08b91e6bc8fd5b758d @halogenandtoast halogenandtoast committed Mar 12, 2012
@@ -1,6 +1,6 @@
class DashboardsController < ApplicationController
def show
- @shout = Shout.new
+ @text_shout = TextShout.new
@shouts = current_user.shouts.current
end
end
@@ -0,0 +1,8 @@
+class TextShoutsController < ApplicationController
+ def create
+ text_shout = TextShout.new(params[:text_shout])
+ shout = current_user.shouts.new(medium: text_shout)
+ shout.save
+ redirect_to dashboard_path, notice: "Shouted!"
+ end
+end
@@ -1,6 +1,10 @@
<h1>Dashboard</h1>
Welcome <%= current_user.email %> - <%= link_to "Sign out", sign_out_path, method: :delete %>
+<%= form_for(@text_shout) do |form| %>
+ <%= form.text_field :body, placeholder: "Shout here" %>
+ <%= form.submit "Shout!" %>
+<% end %>
<div id="shouts">
<%= render @shouts %>
View
@@ -1,5 +1,6 @@
Shouter::Application.routes.draw do
root to: "welcome#index"
resource :dashboard, only: [:show]
- resources :shouts, only: [:create, :show]
+ resources :shouts, only: [:show]
+ resources :text_shouts, only: [:create]
end

0 comments on commit 03aa2ca

Please sign in to comment.