Class: RailsAgents::PullsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_agents/pulls_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

Deprecated: JSON pull from embed bridge. Prefer local app/agents/ + rails-agents sync. Kept for CLI rails-agents pull and backward compatibility until cloud authoring is removed.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/rails_agents/pulls_controller.rb', line 9

def create
  load_local_credentials!

  unless RailsAgents.config.configured?
    return render json: { ok: false, error: "Not connected to Rails Agent Cloud" }, status: :unprocessable_entity
  end

  agent_id = params[:agent_id].presence || params[:agent].presence || params.dig(:pull, :agent_id)
  if agent_id.blank?
    return render json: { ok: false, error: "agent_id is required" }, status: :bad_request
  end

  result = LocalSync.new.pull!(agent_id)
  render json: result
rescue LocalSync::Error, Client::Error => e
  render json: { ok: false, error: e.message }, status: :unprocessable_entity
end