Permalink
Browse files

fixed #28 can create bills

  • Loading branch information...
1 parent 274c986 commit 4db94c07cc87e8ed5d4990fc41c5faade282113c Robert McLeod committed Apr 29, 2012
View
@@ -1,4 +1,3 @@
class Bill < ActiveRecord::Base
- has_many :sections
- attr_accessible :name
+ attr_accessible :markdown, :name
end
@@ -15,6 +15,10 @@
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
+ <div class="field">
+ <%= f.label :markdown %><br />
+ <%= f.text_area :markdown %>
+ </div>
<div class="actions">
<%= f.submit %>
</div>
@@ -3,6 +3,7 @@
<table>
<tr>
<th>Name</th>
+ <th>Markdown</th>
<th></th>
<th></th>
<th></th>
@@ -11,6 +12,7 @@
<% @bills.each do |bill| %>
<tr>
<td><%= bill.name %></td>
+ <td><%= bill.markdown %></td>
<td><%= link_to 'Show', bill %></td>
<td><%= link_to 'Edit', edit_bill_path(bill) %></td>
<td><%= link_to 'Destroy', bill, confirm: 'Are you sure?', method: :delete %></td>
@@ -5,6 +5,11 @@
<%= @bill.name %>
</p>
+<p>
+ <b>Markdown:</b>
+ <%= @bill.markdown %>
+</p>
+
<%= link_to 'Edit', edit_bill_path(@bill) %> |
<%= link_to 'Back', bills_path %>
View
@@ -50,7 +50,7 @@
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
- # root :to => 'welcome#index'
+ root :to => 'bills#index'
# See how all your routes lay out with "rake routes"
@@ -0,0 +1,10 @@
+class CreateBills < ActiveRecord::Migration
+ def change
+ create_table :bills do |t|
+ t.string :name
+ t.text :markdown
+
+ t.timestamps
+ end
+ end
+end
View
@@ -0,0 +1,23 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20120429121648) do
+
+ create_table "bills", :force => true do |t|
+ t.string "name"
+ t.text "markdown"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+end
View
@@ -5,3 +5,23 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
+
+Bill.create({name: "Template", markdown: "# Title 1
+
+## Article 1
+
+Legislation goes here
+
+## Article 2
+
+Legislation goes here
+
+# Title 2
+
+## Article 1
+
+Legislation goes here
+
+## Article 2
+
+Legislation goes here"})
View
@@ -2,6 +2,8 @@
one:
name: MyString
+ markdown: MyText
two:
name: MyString
+ markdown: MyText
@@ -18,7 +18,7 @@ class BillsControllerTest < ActionController::TestCase
test "should create bill" do
assert_difference('Bill.count') do
- post :create, bill: { name: @bill.name }
+ post :create, bill: { markdown: @bill.markdown, name: @bill.name }
end
assert_redirected_to bill_path(assigns(:bill))
@@ -35,7 +35,7 @@ class BillsControllerTest < ActionController::TestCase
end
test "should update bill" do
- put :update, id: @bill, bill: { name: @bill.name }
+ put :update, id: @bill, bill: { markdown: @bill.markdown, name: @bill.name }
assert_redirected_to bill_path(assigns(:bill))
end

0 comments on commit 4db94c0

Please sign in to comment.