Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
lesson 2 conclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
subrb committed Mar 6, 2012
1 parent 8cdfb9e commit 2c462f9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/models/restaurant.rb
@@ -1,3 +1,6 @@
class Restaurant < ActiveRecord::Base class Restaurant < ActiveRecord::Base
belongs_to :ethnic_group
accepts_nested_attributes_for :ethnic_group

validates :name, :presence => true validates :name, :presence => true
end end
7 changes: 7 additions & 0 deletions app/views/restaurants/_form.html.erb
Expand Up @@ -23,6 +23,13 @@
<%= f.label :price %><br /> <%= f.label :price %><br />
<%= f.number_field :price %> <%= f.number_field :price %>
</div> </div>

<div class="ethnic_group">
<%= f.fields_for :ethnic_group do |e| %>
<%= e.text_field :name %>
<% end %>
</div>

<div class="actions"> <div class="actions">
<%= f.submit %> <%= f.submit %>
</div> </div>
Expand Down
16 changes: 13 additions & 3 deletions db/schema.rb
Expand Up @@ -11,14 +11,24 @@
# #
# 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 => 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| create_table "restaurants", :force => true do |t|
t.string "name" t.string "name"
t.boolean "byob" t.boolean "byob"
t.integer "price" t.integer "price"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "ethnic_group_id"
end end


add_index "restaurants", ["ethnic_group_id"], :name => "index_restaurants_on_ethnic_group_id"

end end

0 comments on commit 2c462f9

Please sign in to comment.