Skip to content

Commit

Permalink
Including React.addons. Refactoring 'Record' addRecord and deleteReco…
Browse files Browse the repository at this point in the history
…rd methods
  • Loading branch information
fervisa committed May 18, 2015
1 parent 1a4dc64 commit d19127f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app/assets/javascripts/components/records.js.coffee
Expand Up @@ -21,14 +21,12 @@
@debits() + @credits()

addRecord: (record) ->
records = @state.records.slice()
records.push record
records = React.addons.update(@state.records, { $push: [record] })
@setState records: records

deleteRecord: (record) ->
records = @state.records.slice()
index = records.indexOf record
records.splice index, 1
index = @state.records.indexOf record
records = React.addons.update(@state.records, { $splice: [[index, 1]] })
@replaceState records: records

render: ->
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Expand Up @@ -22,5 +22,7 @@ class Application < Rails::Application

# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true

config.react.addons = true
end
end

0 comments on commit d19127f

Please sign in to comment.