Permalink
Browse files

Add channel to instrument

  • Loading branch information...
1 parent 897a12c commit f286a0fb4454d8bb0a79e119665e54cac8c72f75 Marc Lagrange committed Jun 28, 2011
View
2 app/models/instrument.rb
@@ -47,6 +47,7 @@ class Instrument < ActiveRecord::Base
validates_length_of :synth_end_vshift, :maximum => 2
validates_format_of :synth_end_vshift, :with => /^[A-F0-9]{2}$/, :if => Proc.new { |rec| rec.type == "WAVE" }
validates :sample, :file_size => { :maximum => 128.kilobyte.to_i }
+ validates_inclusion_of :channel, :in => ["", "PU1", "PU2", "WAV", "NOI"] # "" are for the blank "undecided" choice
def set_upcase_fields
self.instrument_name.upcase! if !self.instrument_name.blank?
@@ -77,5 +78,6 @@ def set_upcase_fields
self.vib_type.upcase! if !self.vib_type.blank?
self.automate.upcase! if !self.automate.blank?
self.table.upcase! if !self.table.blank?
+ self.channel.upcase! if !self.channel.blank?
end
end
View
3 app/views/instruments/_form_noise.html.haml
@@ -4,6 +4,9 @@
%td= @instrument.type
= f.hidden_field :type, :value => @instrument.type
%tr
+ %td= label_tag :channel
+ %td= f.select :channel, ["PU1", "PU2", "WAV", "NOI"], :include_blank => true
+ %tr
%td= f.label :envelope
%td= f.text_field :envelope, :size => 2, :maxlength => 2
%tr
View
3 app/views/instruments/_form_pulse.html.haml
@@ -4,6 +4,9 @@
%td= @instrument.type
= f.hidden_field :type, :value => @instrument.type
%tr
+ %td= label_tag :channel
+ %td= f.select :channel, ["PU1", "PU2", "WAV", "NOI"], :include_blank => true
+ %tr
%td= f.label :envelope
%td= f.text_field :envelope, :size => 2, :maxlength => 2
%tr
View
3 app/views/instruments/_form_wave.html.haml
@@ -4,6 +4,9 @@
%td{:width => "70px"}= @instrument.type
= f.hidden_field :type, :value => @instrument.type
%tr
+ %td= label_tag :channel
+ %td= f.select :channel, ["PU1", "PU2", "WAV", "NOI"], :include_blank => true
+ %tr
%td= f.label :volume
%td= f.select :volume, ["0", "1", "2", "3"]
%tr
View
9 db/migrate/20110628061300_add_channel_to_instrument.rb
@@ -0,0 +1,9 @@
+class AddChannelToInstrument < ActiveRecord::Migration
+ def self.up
+ add_column :instruments, :channel, :string, :limit => 5
+ end
+
+ def self.down
+ remove_column :instruments, :channel
+ end
+end
View
3 db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110628054624) do
+ActiveRecord::Schema.define(:version => 20110628061300) do
create_table "comments", :force => true do |t|
t.text "comment"
@@ -58,6 +58,7 @@
t.string "instrument_name", :limit => 5
t.integer "user_id"
t.string "sample"
+ t.string "channel", :limit => 5
end
create_table "slugs", :force => true do |t|

0 comments on commit f286a0f

Please sign in to comment.