Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9fc14c
commit f203005
Showing
12 changed files
with
192 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
class Suggestion < ActiveRecord::Base | |||
validates :title, :presence => true | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.
Sorry, something went wrong. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
<h1>New suggestion</h1> | |||
|
|||
<%= render 'form' %> | |||
<%= link_to 'Back', suggestions_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.
Sorry, something went wrong.
phiggins
Member
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
# Read about fixtures at | |||
# http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html | |||
|
|||
one: | |||
title: MyString | |||
|
|||
two: | |||
title: MyString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
Why not just have the suggestions index copy the style from the talks index?