Skip to content

Commit

Permalink
Talk topic suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
thagomizer committed Jan 24, 2013
1 parent c9fc14c commit f203005
Show file tree
Hide file tree
Showing 12 changed files with 192 additions and 44 deletions.
32 changes: 32 additions & 0 deletions app/controllers/suggestions_controller.rb
@@ -0,0 +1,32 @@
class SuggestionsController < ApplicationController
# GET /suggestions
def index
@suggestions = Suggestion.all

respond_to do |format|
format.html # index.html.erb
end
end

# GET /suggestions/new
def new
@suggestion = Suggestion.new

respond_to do |format|
format.html # new.html.erb
end
end

# POST /suggestions
def create
@suggestion = Suggestion.new(params[:suggestion])

respond_to do |format|
if @suggestion.save
format.html { redirect_to suggestions_path, notice: 'Suggestion was successfully created.' }
else
format.html { render action: "new" }
end
end
end
end
3 changes: 3 additions & 0 deletions app/models/suggestion.rb
@@ -0,0 +1,3 @@
class Suggestion < ActiveRecord::Base
validates :title, :presence => true
end
21 changes: 21 additions & 0 deletions app/views/suggestions/_form.html.erb
@@ -0,0 +1,21 @@
<%= form_for(@suggestion) do |f| %>
<% if @suggestion.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@suggestion.errors.count, "error") %> prohibited this suggestion from being saved:</h2>

<ul>
<% @suggestion.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :topic %><br />
<%= f.text_field :title %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
19 changes: 19 additions & 0 deletions app/views/suggestions/index.html.erb
@@ -0,0 +1,19 @@
<h1>Talk Topic Suggestions</h1>
This is a list of topics and questions that people in Seattle.rb would like to have addressed at our monthly talk meetings.
<br/>
<br/>
<table style="margin-left: 10px;">
<tr>
<th style="text-align: left; font-size: 16px">Topic</th>
</tr>

<% @suggestions.each do |suggestion| %>
<tr>
<td><%= suggestion.title %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Suggestion', new_suggestion_path, {:style => 'margin-left: 10px'}%>

This comment has been minimized.

Copy link
@phiggins

phiggins Jan 24, 2013

Member

Why not just have the suggestions index copy the style from the talks index?

5 changes: 5 additions & 0 deletions app/views/suggestions/new.html.erb
@@ -0,0 +1,5 @@
<h1>New suggestion</h1>

<%= render 'form' %>
<%= link_to 'Back', suggestions_path %>
2 changes: 2 additions & 0 deletions app/views/talks/index.html.erb
Expand Up @@ -39,3 +39,5 @@
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
<%= link_to 'Suggest a Topic For a Talk', suggestions_path, {:style => 'font-size 16px; font-weight: bold'} -%>
4 changes: 4 additions & 0 deletions config/routes.rb
@@ -1,4 +1,8 @@
SeattlerbOrg::Application.routes.draw do SeattlerbOrg::Application.routes.draw do
resources :suggestions, :only => [:index, :new, :create]

resources :helps

This comment has been minimized.

Copy link
@zenspider

zenspider Jan 24, 2013

Member

no


mount RailsAdmin::Engine => '/adminsrb', :as => 'rails_admin' mount RailsAdmin::Engine => '/adminsrb', :as => 'rails_admin'


devise_for :users devise_for :users
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20130124033130_create_suggestions.rb
@@ -0,0 +1,9 @@
class CreateSuggestions < ActiveRecord::Migration
def change
create_table :suggestions do |t|
t.string :title

t.timestamps
end
end
end

This comment has been minimized.

Copy link
@phiggins

phiggins Jan 24, 2013

Member

Should we keep track of who suggested a talk? This would let us twist the arms of people suggesting lots of talks to do their own.

94 changes: 50 additions & 44 deletions db/schema.rb
Expand Up @@ -11,50 +11,56 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.


ActiveRecord::Schema.define(:version => 20130110050659) do ActiveRecord::Schema.define(:version => 20130124033130) do


create_table "affiliations", :force => true do |t| create_table "affiliations", :force => true do |t|
t.integer "dude_id" t.integer "dude_id"
t.integer "project_id" t.integer "project_id"
t.timestamp "created_at" t.datetime "created_at"
t.timestamp "updated_at" t.datetime "updated_at"
end end


create_table "dudes", :force => true do |t| create_table "dudes", :force => true do |t|
t.string "name" t.string "name"
t.string "email" t.string "email"
t.text "bio" t.text "bio", :limit => 255
t.string "website" t.string "website"
t.timestamp "created_at" t.datetime "created_at"
t.timestamp "updated_at" t.datetime "updated_at"
t.string "ruby_gems_id" t.string "ruby_gems_id"
t.boolean "featured", :default => false t.boolean "featured", :default => false
t.string "twitter" t.string "twitter"
t.string "github" t.string "github"
t.string "image_url" t.string "image_url"
end end


create_table "projects", :force => true do |t| create_table "projects", :force => true do |t|
t.string "name" t.string "name"
t.string "url" t.string "url"
t.text "description" t.text "description"
t.timestamp "created_at" t.datetime "created_at"
t.timestamp "updated_at" t.datetime "updated_at"
end end


create_table "rails_admin_histories", :force => true do |t| create_table "rails_admin_histories", :force => true do |t|
t.text "message" t.text "message"
t.string "username" t.string "username"
t.integer "item" t.integer "item"
t.string "table" t.string "table"
t.integer "month" t.integer "month", :limit => 2
t.integer "year" t.integer "year", :limit => 5
t.timestamp "created_at" t.datetime "created_at"
t.timestamp "updated_at" t.datetime "updated_at"
end end


add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories" add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories"


create_table "suggestions", :force => true do |t|
t.string "title"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "talks", :force => true do |t| create_table "talks", :force => true do |t|
t.string "title" t.string "title"
t.text "description" t.text "description"
Expand All @@ -66,21 +72,21 @@
end end


create_table "users", :force => true do |t| create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token" t.string "reset_password_token"
t.timestamp "reset_password_sent_at" t.datetime "reset_password_sent_at"
t.timestamp "remember_created_at" t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0 t.integer "sign_in_count", :default => 0
t.timestamp "current_sign_in_at" t.datetime "current_sign_in_at"
t.timestamp "last_sign_in_at" t.datetime "last_sign_in_at"
t.string "current_sign_in_ip" t.string "current_sign_in_ip"
t.string "last_sign_in_ip" t.string "last_sign_in_ip"
t.timestamp "created_at" t.datetime "created_at"
t.timestamp "updated_at" t.datetime "updated_at"
t.string "confirmation_token" t.string "confirmation_token"
t.timestamp "confirmed_at" t.datetime "confirmed_at"
t.timestamp "confirmation_sent_at" t.datetime "confirmation_sent_at"
end end


add_index "users", ["email"], :name => "index_users_on_email", :unique => true add_index "users", ["email"], :name => "index_users_on_email", :unique => true
Expand Down
26 changes: 26 additions & 0 deletions test/controllers/suggestions_controller_test.rb
@@ -0,0 +1,26 @@
require "minitest_helper"

class SuggestionsControllerTest < MiniTest::Rails::ActionController::TestCase

before do
@suggestion = suggestions(:one)
end

def test_index
get :index
assert_response :success
assert_not_nil assigns(:suggestions)
end

def test_new
get :new
assert_response :success
end

def test_create
assert_difference('Suggestion.count', 1) do
post :create, suggestion: {:title => "My title" }
end
assert_redirected_to suggestions_path
end
end
8 changes: 8 additions & 0 deletions test/fixtures/suggestions.yml
@@ -0,0 +1,8 @@
# Read about fixtures at
# http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html

one:
title: MyString

two:
title: MyString
13 changes: 13 additions & 0 deletions test/models/suggestion_test.rb
@@ -0,0 +1,13 @@
require "minitest_helper"

class SuggestionTest < MiniTest::Rails::ActiveSupport::TestCase
def test_valid
suggestion = Suggestion.new(:title => "WOOT")
assert suggestion.valid?
end

def test_invalid
suggestion = Suggestion.new()
refute suggestion.valid?
end
end

0 comments on commit f203005

Please sign in to comment.