ruby on rails - best_in_place update nested attribute and refresh -
i'm using best_in_place gem edit nested attribute :recommendation of @holding belongs_to @client (which has_many @holdings). done on show view of clients. attribute updating , saving. stays on page. however, have several additional fields on page dependent on :recommendation value , therefore requiring full page refresh update. how can cause refresh automatically?
best_in_place call on clients/show:
<%= best_in_place holding, :recommendation, url: holding_path(holding.id), as: :input, param: "client[holding_attributes][id]=#{holding.id}&holding" %>
holdings controller:
def update respond_to |format| if @holding.update(holding_params) format.html { redirect_to @holding, notice: 'holding updated.' } format.json { render :show, status: :ok, location: @holding } else format.html { render :edit } format.json { render json: @holding.errors, status: :unprocessable_entity } end end end
and rails console shows when edit best_in_place field:
started put "/holdings/28" xxx @ 2017-07-26 02:26:04 +0000 processing holdingscontroller#update json parameters: {"client"=>{"holding_attributes"=>{"id"=>"28"}}, "holding"=>{"recommendation"=>"1234"}, "authenticity_token"=>"v/nsrewfucc++yepqxmwwzldtmpun5uc66cktseki640xwxismazlmljq9cypfc6gh0snh8g8oteybmgx1kgnw==", "id"=>"28"} holding load (0.3ms) select "holdings".* "holdings" "holdings"."id" = ? limit 1 [["id", 28]] (0.1ms) begin transaction sql (0.3ms) update "holdings" set "recommendation" = ?, "updated_at" = ? "holdings"."id" = ? [["recommendation", 1234], ["updated_at", "2017-07-26 02:26:04.646347"], ["id", 28]] client load (0.1ms) select "clients".* "clients" "clients"."id" = ? limit 1 [["id", 2]] sql (0.2ms) update "clients" set "updated_at" = '2017-07-26 02:26:04.648993' "clients"."id" = ? [["id", 2]] (14.2ms) commit transaction rendered holdings/_holding.json.jbuilder (0.5ms) rendered holdings/show.json.jbuilder (1.8ms)
Comments
Post a Comment