Class: Dbhero::DataclipsController
Instance Method Summary
collapse
#_current_user, #call_custom_auth, #check_auth, #user_representation
Instance Method Details
#create ⇒ Object
55
56
57
58
|
# File 'app/controllers/dbhero/dataclips_controller.rb', line 55
def create
@dataclip = Dataclip.create(dataclip_params.merge(user: user_representation))
respond_with @dataclip, location: edit_dataclip_path(@dataclip),notice: 'Dataclip was successfully created.'
end
|
#destroy ⇒ Object
65
66
67
68
|
# File 'app/controllers/dbhero/dataclips_controller.rb', line 65
def destroy
@dataclip.destroy
redirect_to dataclips_url, notice: 'Dataclip was successfully destroyed.'
end
|
#drive ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/dbhero/dataclips_controller.rb', line 17
def drive
token = session.delete(:clip_token)
google_client.fetch_access_token!(params[:code])
google_client.options[:import_data_url] = dataclip_url(id: token, format: 'csv')
google_client.export_clip_by_token token
redirect_to dataclip_path(google_client.dataclip, gdrive_file_url: google_client.exported_file_url)
end
|
#edit ⇒ Object
51
52
53
|
# File 'app/controllers/dbhero/dataclips_controller.rb', line 51
def edit
@dataclip.query_result
end
|
#index ⇒ Object
13
14
15
|
# File 'app/controllers/dbhero/dataclips_controller.rb', line 13
def index
@dataclips = apply_scopes(Dataclip.ordered)
end
|
#new ⇒ Object
47
48
49
|
# File 'app/controllers/dbhero/dataclips_controller.rb', line 47
def new
@dataclip = Dataclip.new
end
|
#show ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/dbhero/dataclips_controller.rb', line 27
def show
check_auth if @dataclip.private?
@dataclip.query_result
respond_to do |format|
format.html do
return render :show, layout: false if request.xhr?
if params[:export_gdrive]
session[:clip_token] = @dataclip.token
redirect_to google_client.auth.authorization_uri.to_s
end
end
format.csv do
send_data @dataclip.csv_string, type: Mime::CSV, disposition: "attachment; filename=#{@dataclip.token}.csv"
end
end
end
|
#update ⇒ Object
60
61
62
63
|
# File 'app/controllers/dbhero/dataclips_controller.rb', line 60
def update
@dataclip.update(dataclip_params)
respond_with @dataclip, location: edit_dataclip_path(@dataclip), notice: 'Dataclip was successfully updated.'
end
|