Skip to content

Commit a138355

Browse files
unknownunknown
unknown
authored and
unknown
committed
Added duration field for movies
1 parent 3416d03 commit a138355

File tree

7 files changed

+15
-2
lines changed

7 files changed

+15
-2
lines changed

app/models/movie.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Movie < ActiveRecord::Base
2-
attr_accessible :lastWatched, :title, :dvd, :actors, :genres
2+
attr_accessible :lastWatched, :title, :dvd, :duration, :actors, :genres
33

44
validates :title, :presence => true
55
validates :dvd, :presence => true

app/views/movies/_form.html.erb

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
<%= movie_form.label :title %><br />
1818
<%= movie_form.text_field :title %>
1919
</div>
20+
<div class="field">
21+
<%= movie_form.label :duration %><br />
22+
<%= movie_form.number_field :duration %>
23+
</div>
2024
<div class="field">
2125
<%= movie_form.label :dvd %><br />
2226
<%= movie_form.check_box :dvd %>

app/views/movies/index.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<% if movie.lastWatched %>
1919
<p>Last Watched: <span class="lastwatched"><%= movie.lastWatched %></span></p>
2020
<% end %>
21+
<p>Duration: <span class="lastwatched"><%= movie.duration %><% if movie.duration %> minutes<% end %></span></p>
2122
<div>
2223
<% movie.actors.each do |actor| %>
2324
<%= link_to actor.name, actor %><% if actor != movie.actors.last %>, <% end %>

app/views/movies/show.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<% if @movie.lastWatched %>
1616
<p>Last Watched: <span class="lastwatched"><%= @movie.lastWatched %></span></p>
1717
<% end %>
18+
<p>Duration: <span class="lastwatched"><%= @movie.duration %><% if movie.duration %> minutes<% end %></span></p>
1819
<ul>
1920
<% @movie.actors.each do |actor| %>
2021
<li><%= link_to actor.name, actor %></li>

app/views/search/index.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<% if movie.lastWatched %>
1717
<p>Last Watched: <span class="lastwatched"><%= movie.lastWatched %></span></p>
1818
<% end %>
19+
<p>Duration: <span class="lastwatched"><%= movie.duration %><% if movie.duration %> minutes<% end %></span></p>
1920
<div>
2021
<% movie.actors.each do |actor| %>
2122
<%= link_to actor.name, actor %><% if actor != movie.actors.last %>, <% end %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddDurationToMovie < ActiveRecord::Migration
2+
def change
3+
add_column :movies, :duration, :integer
4+
end
5+
end

db/schema.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20130208062547) do
14+
ActiveRecord::Schema.define(:version => 20130223051340) do
1515

1616
create_table "actors", :force => true do |t|
1717
t.string "firstname"
@@ -45,6 +45,7 @@
4545
t.date "lastWatched"
4646
t.datetime "created_at", :null => false
4747
t.datetime "updated_at", :null => false
48+
t.integer "duration"
4849
end
4950

5051
end

0 commit comments

Comments
 (0)