ib-ruby 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/HISTORY +3 -0
- data/README.md +29 -9
- data/VERSION +1 -1
- data/app/assets/javascripts/ib/bars.js +2 -0
- data/app/assets/javascripts/ib/executions.js +2 -0
- data/app/assets/javascripts/ib/order_states.js +2 -0
- data/app/assets/stylesheets/ib/bars.css +4 -0
- data/app/assets/stylesheets/ib/executions.css +4 -0
- data/app/assets/stylesheets/ib/order_states.css +4 -0
- data/app/controllers/ib/bars_controller.rb +87 -0
- data/app/controllers/ib/combo_legs_controller.rb +87 -0
- data/app/controllers/ib/contract_details_controller.rb +87 -0
- data/app/controllers/ib/contracts_controller.rb +87 -0
- data/app/controllers/ib/executions_controller.rb +87 -0
- data/app/controllers/ib/order_states_controller.rb +87 -0
- data/app/controllers/ib/orders_controller.rb +87 -0
- data/app/helpers/ib/bars_helper.rb +4 -0
- data/app/helpers/ib/combo_legs_helper.rb +4 -0
- data/app/helpers/ib/contract_details_helper.rb +4 -0
- data/app/helpers/ib/contracts_helper.rb +4 -0
- data/app/helpers/ib/executions_helper.rb +4 -0
- data/app/helpers/ib/order_states_helper.rb +4 -0
- data/app/helpers/ib/orders_helper.rb +4 -0
- data/app/views/ib/bars/_form.html.erb +57 -0
- data/app/views/ib/bars/edit.html.erb +6 -0
- data/app/views/ib/bars/index.html.erb +41 -0
- data/app/views/ib/bars/new.html.erb +5 -0
- data/app/views/ib/bars/show.html.erb +55 -0
- data/app/views/ib/combo_legs/_form.html.erb +53 -0
- data/app/views/ib/combo_legs/edit.html.erb +6 -0
- data/app/views/ib/combo_legs/index.html.erb +39 -0
- data/app/views/ib/combo_legs/new.html.erb +5 -0
- data/app/views/ib/combo_legs/show.html.erb +55 -0
- data/app/views/ib/contract_details/_form.html.erb +141 -0
- data/app/views/ib/contract_details/edit.html.erb +6 -0
- data/app/views/ib/contract_details/index.html.erb +83 -0
- data/app/views/ib/contract_details/new.html.erb +5 -0
- data/app/views/ib/contract_details/show.html.erb +160 -0
- data/app/views/ib/contracts/_form.html.erb +77 -0
- data/app/views/ib/contracts/edit.html.erb +6 -0
- data/app/views/ib/contracts/index.html.erb +53 -0
- data/app/views/ib/contracts/new.html.erb +5 -0
- data/app/views/ib/contracts/show.html.erb +85 -0
- data/app/views/ib/executions/_form.html.erb +77 -0
- data/app/views/ib/executions/edit.html.erb +6 -0
- data/app/views/ib/executions/index.html.erb +51 -0
- data/app/views/ib/executions/new.html.erb +5 -0
- data/app/views/ib/executions/show.html.erb +80 -0
- data/app/views/ib/order_states/_form.html.erb +93 -0
- data/app/views/ib/order_states/edit.html.erb +6 -0
- data/app/views/ib/order_states/index.html.erb +59 -0
- data/app/views/ib/order_states/new.html.erb +5 -0
- data/app/views/ib/order_states/show.html.erb +100 -0
- data/app/views/ib/orders/_form.html.erb +353 -0
- data/app/views/ib/orders/edit.html.erb +6 -0
- data/app/views/ib/orders/index.html.erb +193 -0
- data/app/views/ib/orders/new.html.erb +5 -0
- data/app/views/ib/orders/show.html.erb +435 -0
- data/bin/scaffold.rb +29 -0
- data/config/routes.rb +8 -1
- data/db/config.yml +5 -0
- data/db/migrate/101_add_ib_executions.rb +3 -0
- data/db/migrate/111_add_ib_bars.rb +6 -0
- data/db/migrate/121_add_ib_order_states.rb +8 -0
- data/db/migrate/131_add_ib_orders.rb +24 -0
- data/db/migrate/141_add_ib_combo_legs.rb +6 -0
- data/db/migrate/151_add_ib_underlyings.rb +3 -0
- data/db/migrate/161_add_ib_contract_details.rb +11 -0
- data/db/migrate/171_add_ib_contracts.rb +8 -1
- data/db/schema.rb +6 -5
- data/lib/ib/base.rb +3 -1
- data/lib/ib/base_properties.rb +26 -15
- data/lib/ib/connection.rb +3 -2
- data/lib/ib/errors.rb +16 -9
- data/lib/ib/extensions.rb +6 -4
- data/lib/ib/symbols.rb +10 -3
- data/lib/ib/symbols/forex.rb +49 -64
- data/lib/ib/symbols/futures.rb +2 -3
- data/lib/ib/symbols/options.rb +2 -1
- data/lib/ib/symbols/stocks.rb +2 -1
- data/lib/models/ib/bar.rb +6 -2
- data/lib/models/ib/combo_leg.rb +4 -3
- data/lib/models/ib/contract.rb +9 -5
- data/lib/models/ib/contract_detail.rb +1 -1
- data/lib/models/ib/execution.rb +3 -1
- data/lib/models/ib/order.rb +22 -20
- data/lib/models/ib/order_state.rb +4 -2
- data/lib/models/ib/underlying.rb +3 -4
- data/spec/README.md +12 -10
- data/spec/ib/symbols/symbols_spec.rb +10 -0
- data/spec/integration_helper.rb +1 -1
- data/spec/model_helper.rb +9 -8
- data/spec/models/ib/combo_leg_spec.rb +29 -28
- data/spec/models/ib/contract_detail_spec.rb +4 -1
- data/spec/models/ib/contract_spec.rb +66 -58
- data/spec/models/ib/execution_spec.rb +50 -44
- data/spec/models/ib/order_spec.rb +2 -2
- data/spec/order_helper.rb +5 -4
- data/spec/spec_helper.rb +3 -3
- metadata +59 -35
- data/app/models/ib/underlying.rb +0 -5
- data/bin/account_info +0 -29
- data/bin/cancel_orders +0 -27
- data/bin/contract_details +0 -35
- data/bin/depth_of_market +0 -43
- data/bin/fa_accounts +0 -22
- data/bin/fundamental_data +0 -39
- data/bin/historic_data +0 -51
- data/bin/historic_data_cli +0 -182
- data/bin/list_orders +0 -28
- data/bin/market_data +0 -41
- data/bin/option_data +0 -44
- data/bin/place_combo_order +0 -58
- data/bin/place_order +0 -27
- data/bin/template +0 -18
- data/bin/tick_data +0 -26
- data/bin/time_and_sales +0 -53
data/.gitignore
CHANGED
data/HISTORY
CHANGED
data/README.md
CHANGED
|
@@ -70,7 +70,7 @@ other API implementations. The choice is yours.
|
|
|
70
70
|
| 0.5.21 | 918-920 | 965 |
|
|
71
71
|
| 0.6.1 | 921-923 | 966 |
|
|
72
72
|
| 0.7.1 | 924-925 | 966 |
|
|
73
|
-
| 0.8.1+ | 926-
|
|
73
|
+
| 0.8.1+ | 926-929 | 967 |
|
|
74
74
|
|
|
75
75
|
4. Start Interactive Broker's Trader Work Station or Gateway before your code
|
|
76
76
|
attempts to connect to it. Note that TWS and Gateway listen to different ports,
|
|
@@ -119,9 +119,11 @@ See `lib/ib/messages` for a full list of supported incoming/outgoing messages
|
|
|
119
119
|
and their attributes. The original TWS docs and code samples can also be found
|
|
120
120
|
in `misc` directory.
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
Sample scripts in `example` directory demonstrate common ib-ruby use cases. Examples
|
|
123
|
+
show you how to access account info, print real time quotes, retrieve historic or
|
|
124
|
+
fundamental data, request options calculations, place, list, and cancel orders.
|
|
125
|
+
You may also want to look into `spec/integration` directory for more scenarios,
|
|
126
|
+
use cases and examples of handling IB messages.
|
|
125
127
|
|
|
126
128
|
## RAILS INTEGRATION:
|
|
127
129
|
|
|
@@ -185,13 +187,31 @@ JRuby head (ruby-1.9.3-p203-compatible mode). It is not JRuby-specific though, a
|
|
|
185
187
|
for either JRuby or MRI, please report an [issue](https://github.com/ib-ruby/ib-ruby/issues/new)
|
|
186
188
|
and we will work on it.
|
|
187
189
|
|
|
190
|
+
Please keep in mind that when using Ruby 1.8.7, you need to either explicitly:
|
|
191
|
+
``` ruby
|
|
192
|
+
require 'rubygems'
|
|
193
|
+
require 'ib'
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
or set the environment variable "RUBYOPT" to "-rubygems":
|
|
197
|
+
|
|
198
|
+
set RUBYOPT=-rubygems
|
|
199
|
+
|
|
188
200
|
## CONTRIBUTING:
|
|
189
201
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
202
|
+
If you want to contribute to ib-ruby development:
|
|
203
|
+
|
|
204
|
+
1. Make a fresh fork of ib-ruby (Fork button on top of Github GUI)
|
|
205
|
+
2. Clone your fork locally (git clone /your fork private URL/)
|
|
206
|
+
3. Add main ib-ruby repo as upstream (git remote add upstream git://github.com/ib-ruby/ib-ruby.git)
|
|
207
|
+
4. Create your feature branch (git checkout -b my-new-feature)
|
|
208
|
+
5. Modify code as you see fit
|
|
209
|
+
6. Commit your changes (git commit -am 'Added some feature')
|
|
210
|
+
7. Pull in latest upstream changes (git fetch upstream -v; git merge upstream/master)
|
|
211
|
+
8. Push to the branch (git push origin my-new-feature)
|
|
212
|
+
9. Go to your Github fork and create new Pull Request via Github GUI
|
|
213
|
+
|
|
214
|
+
... then proceed from step 6 for more code modifications...
|
|
195
215
|
|
|
196
216
|
## LICENSE:
|
|
197
217
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.8.
|
|
1
|
+
0.8.5
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require_dependency "ib/application_controller"
|
|
2
|
+
|
|
3
|
+
module Ib
|
|
4
|
+
class BarsController < ApplicationController
|
|
5
|
+
# GET /bars
|
|
6
|
+
# GET /bars.json
|
|
7
|
+
def index
|
|
8
|
+
@bars = Bar.all
|
|
9
|
+
|
|
10
|
+
respond_to do |format|
|
|
11
|
+
format.html # index.html.erb
|
|
12
|
+
format.json { render :json => @bars }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /bars/1
|
|
17
|
+
# GET /bars/1.json
|
|
18
|
+
def show
|
|
19
|
+
@bar = Bar.find(params[:id])
|
|
20
|
+
|
|
21
|
+
respond_to do |format|
|
|
22
|
+
format.html # show.html.erb
|
|
23
|
+
format.json { render :json => @bar }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# GET /bars/new
|
|
28
|
+
# GET /bars/new.json
|
|
29
|
+
def new
|
|
30
|
+
@bar = Bar.new
|
|
31
|
+
|
|
32
|
+
respond_to do |format|
|
|
33
|
+
format.html # new.html.erb
|
|
34
|
+
format.json { render :json => @bar }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# GET /bars/1/edit
|
|
39
|
+
def edit
|
|
40
|
+
@bar = Bar.find(params[:id])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# POST /bars
|
|
44
|
+
# POST /bars.json
|
|
45
|
+
def create
|
|
46
|
+
@bar = Bar.new(params[:bar])
|
|
47
|
+
|
|
48
|
+
respond_to do |format|
|
|
49
|
+
if @bar.save
|
|
50
|
+
format.html { redirect_to @bar, :notice => 'Bar was successfully created.' }
|
|
51
|
+
format.json { render :json => @bar, :status => :created, :location => @bar }
|
|
52
|
+
else
|
|
53
|
+
format.html { render :action => "new" }
|
|
54
|
+
format.json { render :json => @bar.errors, :status => :unprocessable_entity }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# PUT /bars/1
|
|
60
|
+
# PUT /bars/1.json
|
|
61
|
+
def update
|
|
62
|
+
@bar = Bar.find(params[:id])
|
|
63
|
+
|
|
64
|
+
respond_to do |format|
|
|
65
|
+
if @bar.update_attributes(params[:bar])
|
|
66
|
+
format.html { redirect_to @bar, :notice => 'Bar was successfully updated.' }
|
|
67
|
+
format.json { head :no_content }
|
|
68
|
+
else
|
|
69
|
+
format.html { render :action => "edit" }
|
|
70
|
+
format.json { render :json => @bar.errors, :status => :unprocessable_entity }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# DELETE /bars/1
|
|
76
|
+
# DELETE /bars/1.json
|
|
77
|
+
def destroy
|
|
78
|
+
@bar = Bar.find(params[:id])
|
|
79
|
+
@bar.destroy
|
|
80
|
+
|
|
81
|
+
respond_to do |format|
|
|
82
|
+
format.html { redirect_to bars_url }
|
|
83
|
+
format.json { head :no_content }
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require_dependency "ib/application_controller"
|
|
2
|
+
|
|
3
|
+
module Ib
|
|
4
|
+
class ComboLegsController < ApplicationController
|
|
5
|
+
# GET /combo_legs
|
|
6
|
+
# GET /combo_legs.json
|
|
7
|
+
def index
|
|
8
|
+
@combo_legs = ComboLeg.all
|
|
9
|
+
|
|
10
|
+
respond_to do |format|
|
|
11
|
+
format.html # index.html.erb
|
|
12
|
+
format.json { render :json => @combo_legs }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /combo_legs/1
|
|
17
|
+
# GET /combo_legs/1.json
|
|
18
|
+
def show
|
|
19
|
+
@combo_leg = ComboLeg.find(params[:id])
|
|
20
|
+
|
|
21
|
+
respond_to do |format|
|
|
22
|
+
format.html # show.html.erb
|
|
23
|
+
format.json { render :json => @combo_leg }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# GET /combo_legs/new
|
|
28
|
+
# GET /combo_legs/new.json
|
|
29
|
+
def new
|
|
30
|
+
@combo_leg = ComboLeg.new
|
|
31
|
+
|
|
32
|
+
respond_to do |format|
|
|
33
|
+
format.html # new.html.erb
|
|
34
|
+
format.json { render :json => @combo_leg }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# GET /combo_legs/1/edit
|
|
39
|
+
def edit
|
|
40
|
+
@combo_leg = ComboLeg.find(params[:id])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# POST /combo_legs
|
|
44
|
+
# POST /combo_legs.json
|
|
45
|
+
def create
|
|
46
|
+
@combo_leg = ComboLeg.new(params[:combo_leg])
|
|
47
|
+
|
|
48
|
+
respond_to do |format|
|
|
49
|
+
if @combo_leg.save
|
|
50
|
+
format.html { redirect_to @combo_leg, :notice => 'Combo leg was successfully created.' }
|
|
51
|
+
format.json { render :json => @combo_leg, :status => :created, :location => @combo_leg }
|
|
52
|
+
else
|
|
53
|
+
format.html { render :action => "new" }
|
|
54
|
+
format.json { render :json => @combo_leg.errors, :status => :unprocessable_entity }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# PUT /combo_legs/1
|
|
60
|
+
# PUT /combo_legs/1.json
|
|
61
|
+
def update
|
|
62
|
+
@combo_leg = ComboLeg.find(params[:id])
|
|
63
|
+
|
|
64
|
+
respond_to do |format|
|
|
65
|
+
if @combo_leg.update_attributes(params[:combo_leg])
|
|
66
|
+
format.html { redirect_to @combo_leg, :notice => 'Combo leg was successfully updated.' }
|
|
67
|
+
format.json { head :no_content }
|
|
68
|
+
else
|
|
69
|
+
format.html { render :action => "edit" }
|
|
70
|
+
format.json { render :json => @combo_leg.errors, :status => :unprocessable_entity }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# DELETE /combo_legs/1
|
|
76
|
+
# DELETE /combo_legs/1.json
|
|
77
|
+
def destroy
|
|
78
|
+
@combo_leg = ComboLeg.find(params[:id])
|
|
79
|
+
@combo_leg.destroy
|
|
80
|
+
|
|
81
|
+
respond_to do |format|
|
|
82
|
+
format.html { redirect_to combo_legs_url }
|
|
83
|
+
format.json { head :no_content }
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require_dependency "ib/application_controller"
|
|
2
|
+
|
|
3
|
+
module Ib
|
|
4
|
+
class ContractDetailsController < ApplicationController
|
|
5
|
+
# GET /contract_details
|
|
6
|
+
# GET /contract_details.json
|
|
7
|
+
def index
|
|
8
|
+
@contract_details = ContractDetail.all
|
|
9
|
+
|
|
10
|
+
respond_to do |format|
|
|
11
|
+
format.html # index.html.erb
|
|
12
|
+
format.json { render :json => @contract_details }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /contract_details/1
|
|
17
|
+
# GET /contract_details/1.json
|
|
18
|
+
def show
|
|
19
|
+
@contract_detail = ContractDetail.find(params[:id])
|
|
20
|
+
|
|
21
|
+
respond_to do |format|
|
|
22
|
+
format.html # show.html.erb
|
|
23
|
+
format.json { render :json => @contract_detail }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# GET /contract_details/new
|
|
28
|
+
# GET /contract_details/new.json
|
|
29
|
+
def new
|
|
30
|
+
@contract_detail = ContractDetail.new
|
|
31
|
+
|
|
32
|
+
respond_to do |format|
|
|
33
|
+
format.html # new.html.erb
|
|
34
|
+
format.json { render :json => @contract_detail }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# GET /contract_details/1/edit
|
|
39
|
+
def edit
|
|
40
|
+
@contract_detail = ContractDetail.find(params[:id])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# POST /contract_details
|
|
44
|
+
# POST /contract_details.json
|
|
45
|
+
def create
|
|
46
|
+
@contract_detail = ContractDetail.new(params[:contract_detail])
|
|
47
|
+
|
|
48
|
+
respond_to do |format|
|
|
49
|
+
if @contract_detail.save
|
|
50
|
+
format.html { redirect_to @contract_detail, :notice => 'Contract detail was successfully created.' }
|
|
51
|
+
format.json { render :json => @contract_detail, :status => :created, :location => @contract_detail }
|
|
52
|
+
else
|
|
53
|
+
format.html { render :action => "new" }
|
|
54
|
+
format.json { render :json => @contract_detail.errors, :status => :unprocessable_entity }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# PUT /contract_details/1
|
|
60
|
+
# PUT /contract_details/1.json
|
|
61
|
+
def update
|
|
62
|
+
@contract_detail = ContractDetail.find(params[:id])
|
|
63
|
+
|
|
64
|
+
respond_to do |format|
|
|
65
|
+
if @contract_detail.update_attributes(params[:contract_detail])
|
|
66
|
+
format.html { redirect_to @contract_detail, :notice => 'Contract detail was successfully updated.' }
|
|
67
|
+
format.json { head :no_content }
|
|
68
|
+
else
|
|
69
|
+
format.html { render :action => "edit" }
|
|
70
|
+
format.json { render :json => @contract_detail.errors, :status => :unprocessable_entity }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# DELETE /contract_details/1
|
|
76
|
+
# DELETE /contract_details/1.json
|
|
77
|
+
def destroy
|
|
78
|
+
@contract_detail = ContractDetail.find(params[:id])
|
|
79
|
+
@contract_detail.destroy
|
|
80
|
+
|
|
81
|
+
respond_to do |format|
|
|
82
|
+
format.html { redirect_to contract_details_url }
|
|
83
|
+
format.json { head :no_content }
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require_dependency "ib/application_controller"
|
|
2
|
+
|
|
3
|
+
module Ib
|
|
4
|
+
class ContractsController < ApplicationController
|
|
5
|
+
# GET /contracts
|
|
6
|
+
# GET /contracts.json
|
|
7
|
+
def index
|
|
8
|
+
@contracts = Contract.all
|
|
9
|
+
|
|
10
|
+
respond_to do |format|
|
|
11
|
+
format.html # index.html.erb
|
|
12
|
+
format.json { render :json => @contracts }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /contracts/1
|
|
17
|
+
# GET /contracts/1.json
|
|
18
|
+
def show
|
|
19
|
+
@contract = Contract.find(params[:id])
|
|
20
|
+
|
|
21
|
+
respond_to do |format|
|
|
22
|
+
format.html # show.html.erb
|
|
23
|
+
format.json { render :json => @contract }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# GET /contracts/new
|
|
28
|
+
# GET /contracts/new.json
|
|
29
|
+
def new
|
|
30
|
+
@contract = Contract.new
|
|
31
|
+
|
|
32
|
+
respond_to do |format|
|
|
33
|
+
format.html # new.html.erb
|
|
34
|
+
format.json { render :json => @contract }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# GET /contracts/1/edit
|
|
39
|
+
def edit
|
|
40
|
+
@contract = Contract.find(params[:id])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# POST /contracts
|
|
44
|
+
# POST /contracts.json
|
|
45
|
+
def create
|
|
46
|
+
@contract = Contract.new(params[:contract])
|
|
47
|
+
|
|
48
|
+
respond_to do |format|
|
|
49
|
+
if @contract.save
|
|
50
|
+
format.html { redirect_to @contract, :notice => 'Contract was successfully created.' }
|
|
51
|
+
format.json { render :json => @contract, :status => :created, :location => @contract }
|
|
52
|
+
else
|
|
53
|
+
format.html { render :action => "new" }
|
|
54
|
+
format.json { render :json => @contract.errors, :status => :unprocessable_entity }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# PUT /contracts/1
|
|
60
|
+
# PUT /contracts/1.json
|
|
61
|
+
def update
|
|
62
|
+
@contract = Contract.find(params[:id])
|
|
63
|
+
|
|
64
|
+
respond_to do |format|
|
|
65
|
+
if @contract.update_attributes(params[:contract])
|
|
66
|
+
format.html { redirect_to @contract, :notice => 'Contract was successfully updated.' }
|
|
67
|
+
format.json { head :no_content }
|
|
68
|
+
else
|
|
69
|
+
format.html { render :action => "edit" }
|
|
70
|
+
format.json { render :json => @contract.errors, :status => :unprocessable_entity }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# DELETE /contracts/1
|
|
76
|
+
# DELETE /contracts/1.json
|
|
77
|
+
def destroy
|
|
78
|
+
@contract = Contract.find(params[:id])
|
|
79
|
+
@contract.destroy
|
|
80
|
+
|
|
81
|
+
respond_to do |format|
|
|
82
|
+
format.html { redirect_to contracts_url }
|
|
83
|
+
format.json { head :no_content }
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|