Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Talk topic suggestions

  • Loading branch information...
commit f2030050a16b2b8d759bca5aa9b85e2c3dab2116 1 parent c9fc14c
@thagomizer thagomizer authored
View
32 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
View
3  app/models/suggestion.rb
@@ -0,0 +1,3 @@
+class Suggestion < ActiveRecord::Base
+ validates :title, :presence => true
+end
View
21 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 %>
View
19 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'}%>
@phiggins Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
5 app/views/suggestions/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New suggestion</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', suggestions_path %>
View
2  app/views/talks/index.html.erb
@@ -39,3 +39,5 @@
<% end %>
</div>
<% end %>
+
+<%= link_to 'Suggest a Topic For a Talk', suggestions_path, {:style => 'font-size 16px; font-weight: bold'} -%>
View
4 config/routes.rb
@@ -1,4 +1,8 @@
SeattlerbOrg::Application.routes.draw do
+ resources :suggestions, :only => [:index, :new, :create]
+
+ resources :helps
@zenspider Owner

no

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
mount RailsAdmin::Engine => '/adminsrb', :as => 'rails_admin'
devise_for :users
View
9 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
@phiggins Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
94 db/schema.rb
@@ -11,50 +11,56 @@
#
# 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|
- t.integer "dude_id"
- t.integer "project_id"
- t.timestamp "created_at"
- t.timestamp "updated_at"
+ t.integer "dude_id"
+ t.integer "project_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "dudes", :force => true do |t|
- t.string "name"
- t.string "email"
- t.text "bio"
- t.string "website"
- t.timestamp "created_at"
- t.timestamp "updated_at"
- t.string "ruby_gems_id"
- t.boolean "featured", :default => false
- t.string "twitter"
- t.string "github"
- t.string "image_url"
+ t.string "name"
+ t.string "email"
+ t.text "bio", :limit => 255
+ t.string "website"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "ruby_gems_id"
+ t.boolean "featured", :default => false
+ t.string "twitter"
+ t.string "github"
+ t.string "image_url"
end
create_table "projects", :force => true do |t|
- t.string "name"
- t.string "url"
- t.text "description"
- t.timestamp "created_at"
- t.timestamp "updated_at"
+ t.string "name"
+ t.string "url"
+ t.text "description"
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "rails_admin_histories", :force => true do |t|
- t.text "message"
- t.string "username"
- t.integer "item"
- t.string "table"
- t.integer "month"
- t.integer "year"
- t.timestamp "created_at"
- t.timestamp "updated_at"
+ t.text "message"
+ t.string "username"
+ t.integer "item"
+ t.string "table"
+ t.integer "month", :limit => 2
+ t.integer "year", :limit => 5
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
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|
t.string "title"
t.text "description"
@@ -66,21 +72,21 @@
end
create_table "users", :force => true do |t|
- t.string "email", :default => "", :null => false
- t.string "encrypted_password", :default => "", :null => false
- t.string "reset_password_token"
- t.timestamp "reset_password_sent_at"
- t.timestamp "remember_created_at"
- t.integer "sign_in_count", :default => 0
- t.timestamp "current_sign_in_at"
- t.timestamp "last_sign_in_at"
- t.string "current_sign_in_ip"
- t.string "last_sign_in_ip"
- t.timestamp "created_at"
- t.timestamp "updated_at"
- t.string "confirmation_token"
- t.timestamp "confirmed_at"
- t.timestamp "confirmation_sent_at"
+ t.string "email", :default => "", :null => false
+ t.string "encrypted_password", :default => "", :null => false
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.integer "sign_in_count", :default => 0
+ t.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "confirmation_token"
+ t.datetime "confirmed_at"
+ t.datetime "confirmation_sent_at"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
View
26 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
View
8 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
View
13 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
Please sign in to comment.
Something went wrong with that request. Please try again.