I tried to edit and update columns using Faraday Call on my rails app, I am successfully updating the columns by adding new value.
But I want during update, initially in edit_form, it must show my old values where i can edit it, and then update.
This is my Connection Request
def connection
Faraday.new(url: ENV['URL'],
params: { clientId: ENV['CLIENT_ID'] },
headers: { 'Authorization' => oauth_token_generation })
end
This is my edit_request to call end point for connection and update
def edit_request(type,id, params)
response = connection.patch("#{type}/#{id}", params)
JSON.parse(response.body)
rescue JSON::ParserError
Rails.logger.error 'Invalid Json Data'
nil
rescue Faraday::Error => e
Rails.logger.error "Connection Failed #{e}"
nil
end
This is my calling method:
def self.get_entities(id,params)
response = Api::Connection.edit_request('entities',id, params)
end
My Controller:
def edit
@schemas = Api::ApiCall::Schema.get_entities(params[:id],params)
end
def update
end
This is my Edit Form where I want to initailly retrive all data then edit and update:
<%= form_for(:schemas, url:schemas_path) do |f| %>
<%= f.text_field :schemaId, placeholder:"Schema Id"%>
<%= f.text_area :name, placeholder: "Schema Name"%>
<%= f.text_area :schemaMnemonic, placeholder: "Schema Mnemonic"%>
<%= f.text_area :Mnemonic, placeholder: "Mnemonic"%>
<%= f.text_area :description, placeholder: "Description"%>
<%= f.submit "Save"%>
<% end %>
Aucun commentaire:
Enregistrer un commentaire