Skip to content
Browse files

Made sure colors in the database are downcased so they are matched in…

… the iPhone select list
  • Loading branch information...
1 parent ecc6765 commit e98987673f1c78fe6e745a21546981b723f2e216 Bob Van Landuyt committed Dec 21, 2010
View
6 app/models/interface.rb
@@ -62,7 +62,7 @@ def update_cable_connection
new_connection = CableConnection.new
new_connection.right_interface_id = self.id
new_connection.left_interface_id = self.connected_to
- new_connection.color = self.cable_connection_color
+ new_connection.color = self.cable_connection_color.downcase
new_connection.save!
end
@@ -72,9 +72,9 @@ def update_cable_connection
to_update.destroy
else
if to_update.right_interface_id == self.id
- to_update.update_attributes(:left_interface_id => self.connected_to, :color => self.cable_connection_color)
+ to_update.update_attributes(:left_interface_id => self.connected_to, :color => self.cable_connection_color.downcase)
else
- to_update.update_attributes(:right_interface_id => self.connected_to, :color => self.cable_connection_color)
+ to_update.update_attributes(:right_interface_id => self.connected_to, :color => self.cable_connection_color.downcase)
end
end
end
View
2 app/views/interfaces/_form.iphone.erb
@@ -12,7 +12,7 @@
</div>
<div class="fieldcontain">
<%= form.label :cable_connection_color%>
- <%= form.select :cable_connection_color, ConvertColors.base_colors.map {|color| color.name}, {:prompt => 'Select a color?', :selected => interface.cable_connection.try(:color) } %>
+ <%= form.select :cable_connection_color, ConvertColors.base_colors.map {|color| [color.name, color.name.downcase]}, {:prompt => 'Select a color?', :selected => interface.cable_connection.try(:color) } %>
</div>
<div id="hiddenOptions" style="display: none;">
View
11 db/migrate/20101221095353_downcase_cable_connection_colors.rb
@@ -0,0 +1,11 @@
+class DowncaseCableConnectionColors < ActiveRecord::Migration
+ def self.up
+ CableConnection.all.each do |connection|
+ connection.color = connection.color.downcase
+ connection.save!
+ end
+ end
+
+ def self.down
+ end
+end
View
2 db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20101206102859) do
+ActiveRecord::Schema.define(:version => 20101221095353) do
create_table "cable_connections", :force => true do |t|
t.integer "left_interface_id", :null => false

0 comments on commit e989876

Please sign in to comment.
Something went wrong with that request. Please try again.