blob: 06017da7d569cc43abb7ca0ecb31030c6ba58183 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
class ImportsController < ChouetteController
respond_to :html, :xml, :json
belongs_to :referential
def new
new! do
available_imports
end
end
def create
create! do |success, failure|
available_imports
success.html { redirect_to referential_imports_path(@referential) }
end
end
protected
def available_imports
@available_imports ||= Import.types.collect do |type|
unless @import.type == type
@referential.imports.build :type => type
else
@import
end
end
end
# FIXME why #resource_id is nil ??
def build_resource
super.tap do |import|
import.referential_id = @referential.id
end
end
def collection
@imports ||= end_of_association_chain.paginate(:page => params[:page])
end
end
|