Rimon
Rimon

Reputation: 119

Rails applicaton's rest client post and put method

Using Ruby rest-client, some example given for put and post request. But it's confusing to me for my rails application's client for sending put and post request. Let say, I have developed my Rail application by commands : rails generate scaffold HighScore game:string score:integer , so here is HighScore controller 2 function

class HighScoresController < ApplicationController
  # 1
  # POST /high_scores
  # POST /high_scores.json
  def create

  # 2
  # PATCH/PUT /high_scores/1
  # PATCH/PUT /high_scores/1.json
  def update

end

How can I properly execute post and put request from my client side code, for these 2 scaffold related method #1 #2, if I follow this rest-client example

Upvotes: 2

Views: 555

Answers (1)

matthewdu
matthewdu

Reputation: 43

You need to change application_controller.rb to allow post and put request through an api call.

Change:

protect_from_forgery with: :exception

To:

protect_from_forgery with: :null_session

Upvotes: 2

Related Questions