bookkeeper 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require_dependency "bookkeeper/application_controller"
3
3
  module Bookkeeper
4
4
  class BalanceController < ApplicationController
5
5
  def index
6
- @account = Account.first
6
+ @account = Account.default
7
7
  @movements = @account.movements
8
8
  end
9
9
  end
@@ -29,19 +29,16 @@ module Bookkeeper
29
29
  end
30
30
 
31
31
  def self.default
32
- if account = Account.find_by_default(true)
33
- account
34
- else
35
- Account.create(title: "Default", start_date: Time.now, initial_balance: 0.0, default: true)
36
- end
32
+ account = Account.find_by_default(true)
33
+ account = Account.create(title: "Default", start_date: Time.now, initial_balance: 0.0, default: true) if account.nil?
34
+
35
+ account
37
36
  end
38
37
 
39
38
  protected
40
39
 
41
40
  def default_must_be_uniq
42
- if !self.persisted? && Account.where(default: true).first != self
43
- errors.add(:base, I18n.t(".default_must_be_uniq"))
44
- end
41
+ errors.add(:base, I18n.t(".default_must_be_uniq")) if Account.find_by_default(true)
45
42
  end
46
43
  end
47
44
  end
@@ -1,3 +1,3 @@
1
1
  module Bookkeeper
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookkeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-18 00:00:00.000000000 Z
12
+ date: 2013-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails