Forum: Ruby on Rails How to use Controller instance methods inside (Web Service) API Services

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Piyush with Rails (Guest)
on 2009-03-04 12:15
(Received via mailing list)
Hi All,

I am using AWS to implement web service APIs in rails and i am using
Layered dispatching mode for implementation.

Here i am not getting how can i use controller's instance methods
(both user defined and built in) inside my API service.

As an example below take below things in consideration.

this is API signature.

class ProductApi < ActionWebService::API::Base

     api_method :find_all_products,
     :returns => [[:int]]

    api_method :find_product_by_id,
    :expects => [:int],
     :returns => [Product]

this is layered_backend controller.

class LayeredBackendController < ApplicationController

      dispatching_web_service_mode :layered
      web_service_scaffold :invoke
      web_service(:order) { }

      def test_method
         # some code

this is order_service.rb file.

class OrderService< ActionWebService::Base
     web_service_api ProductApi

     def find_all_products
         Product.find(:all).map{ |product| }

     def find_product_by_id(id)

Now if i want to use my controller instance method named test_method
inside OrderServie then how can i use it ?

and also how to use controller built in instance methods (like
session, log_error etc )inside OrderService ?

Thanks in Advance.

This topic is locked and can not be replied to.