Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added model association

  • Loading branch information...
commit f9a6149fecbe1dc796f399f5f12e611b8db62282 1 parent 72d8219
Amit Kumar authored
View
18 app/app_delegate.rb
@@ -28,14 +28,16 @@ def create_brands_and_associate_levers
brand = @brands[0]
- brand.levers << Lever.create(:name => @lever_names[0], :color => "A2AD01".to_color)
- brand.levers << Lever.create(:name => @lever_names[1], :color => "E47C33".to_color)
- brand.levers << Lever.create(:name => @lever_names[0], :color => "CF2A35".to_color)
- brand.levers << Lever.create(:name => @lever_names[0], :color => "006600".to_color)
- brand.levers << Lever.create(:name => @lever_names[0], :color => "370066".to_color)
- brand.levers << Lever.create(:name => @lever_names[0], :color => "1EB4B8".to_color)
- brand.levers << Lever.create(:name => @lever_names[0], :color => "E47C33".to_color)
- brand.levers << Lever.create(:name => @lever_names[0], :color => "1CA4EE".to_color)
+ p brand.levers
+
+ brand.levers << Lever.create(:name => @lever_names[0], :color => "A2AD01")
+ brand.levers << Lever.create(:name => @lever_names[1], :color => "E47C33")
+ brand.levers << Lever.create(:name => @lever_names[0], :color => "CF2A35")
+ brand.levers << Lever.create(:name => @lever_names[0], :color => "006600")
+ brand.levers << Lever.create(:name => @lever_names[0], :color => "370066")
+ brand.levers << Lever.create(:name => @lever_names[0], :color => "1EB4B8")
+ brand.levers << Lever.create(:name => @lever_names[0], :color => "E47C33")
+ brand.levers << Lever.create(:name => @lever_names[0], :color => "1CA4EE")
end
View
2  app/core_ext/ui_color.rb
@@ -1,5 +1,5 @@
class UIColor
def to_cpt_color
- CPTColor.alloc.initWithColor(self.CGColor)
+ CPTColor.alloc.initWithCGColor(self.CGColor)
end
end
View
16 app/models/brand.rb
@@ -1,9 +1,19 @@
class Brand < NanoStore::Model
+ attr_accessor :levers
+
attribute :name
attribute :description
- bag :levers
+ # bag :levers
+
+ def self.create(data)
+ p "called"
+ object = super
+
+ object.levers = []
+ object
+ end
def curves
start = 0
@@ -11,10 +21,10 @@ def curves
start += 1
{
:name => lever.name,
- :color => lever.color.to_cpt_color,
+ :color => lever.color.to_color.to_cpt_color,
:static_point => start,
:draggable_point => start+1,
- :fn => lambda {|p| (start+1) * p * p},
+ :fn => lambda {|p| 0.5 * p * p},
:data => (0..10).to_a
}
end
Please sign in to comment.
Something went wrong with that request. Please try again.