end
def create
+ @rentable = Rentable.new
+ @rentable.save!
+ puts "created new rentable with ID: #{@rentable.id}"
@video = Video.new(params[:video])
+ @video.rentable_id = @rentable.id
if @video.save
flash[:notice] = 'Video was successfully created.'
redirect_to :action => 'list'
class Rentable < ActiveRecord::Base
has_many :coitem
- validates_presence_of :title
- validates_presence_of :genre
+ #validates_presence_of :genre
end
<%= error_messages_for 'video' %>
<!--[form:video]-->
+<p><label for="video_title">Title</label><br/>
+<%= text_field 'video', 'title' %></p>
+
<p><label for="video_newrelease">Newrelease</label><br/>
<select id="video_newrelease" name="video[newrelease]"><option value="false" selected>False</option><option value="true">True</option></select></p>
--- /dev/null
+class MoveTitleToVideo < ActiveRecord::Migration
+ def self.up
+ add_column :videos, :title, :string
+ remove_column :rentables, :title
+ end
+
+ def self.down
+ remove_column :videos, :title
+ add_column :rentables, :title, :string
+ end
+end
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
-ActiveRecord::Schema.define(:version => 4) do
+ActiveRecord::Schema.define(:version => 5) do
create_table "coitems", :force => true do |t|
t.column "customer_id", :integer
end
create_table "rentables", :force => true do |t|
- t.column "title", :string
t.column "genre", :string
end
t.column "newrelease", :boolean, :default => false
t.column "director", :string
t.column "genre", :integer
+ t.column "title", :string
end
end