Sha256: 2f90b39bf5333935692befecab8f295e0bd9340b68aa2bc6551fc326a6f7d25d

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

class UserController < ApplicationController
  # It will works with respond_with.
  # Your action should looks like any other one: A model with a method call. =D
  def index
    @users = User.get("api.example.com/users")
    respond_with(@users)
  end

  def new
    @user = User.new
    respond_with(@user)
  end

  def create
    @user = User.post("api.example.com/users", :user => params[:user])
    respond_with(@user)
  end

  def edit
    @user = User.get("api.example.com/users/#{params[:id]}")
    respond_with(@user)
  end

  def update
    @user = User.patch("api.example.com/users", { :id => params[:id], :user => params[:user]})
    respond_with(@user)
  end

  def show
    @user = User.get("api.example.com/users/#{params[:id]}")
    respond_with(@user)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
api-client-1.7.1 examples/controllers/user_controller.rb