Permalink
Browse files

lesson 2 conclusion

  • Loading branch information...
subrb committed Mar 6, 2012
1 parent 8cdfb9e commit 2c462f9d7b1db29cb8df29492f94613873b6ebcf
Showing with 23 additions and 3 deletions.
  1. +3 −0 app/models/restaurant.rb
  2. +7 −0 app/views/restaurants/_form.html.erb
  3. +13 −3 db/schema.rb
View
@@ -1,3 +1,6 @@
class Restaurant < ActiveRecord::Base
+ belongs_to :ethnic_group
+ accepts_nested_attributes_for :ethnic_group
+
validates :name, :presence => true
end
@@ -23,6 +23,13 @@
<%= f.label :price %><br />
<%= f.number_field :price %>
</div>
+
+ <div class="ethnic_group">
+ <%= f.fields_for :ethnic_group do |e| %>
+ <%= e.text_field :name %>
+ <% end %>
+ </div>
+
<div class="actions">
<%= f.submit %>
</div>
View
@@ -11,14 +11,24 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120306020306) do
+ActiveRecord::Schema.define(:version => 20120306023428) do
+
+ create_table "ethnic_groups", :force => true do |t|
+ t.string "name"
+ t.text "description"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
create_table "restaurants", :force => true do |t|
t.string "name"
t.boolean "byob"
t.integer "price"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "ethnic_group_id"
end
+ add_index "restaurants", ["ethnic_group_id"], :name => "index_restaurants_on_ethnic_group_id"
+
end

0 comments on commit 2c462f9

Please sign in to comment.