Questions tagged [service-object]

49 questions
1
vote
1 answer

respond_to and service objects

I'm currently using the docx_replace gem to automate the insertion of data into a set of documents. The gem is pretty straightforward; basically it runs in a special method within your rails controller like so (quoting from the documentation): def…
1
vote
2 answers

Google Cloud Endpoint Authentication from my Android Client: Audience not Allowed and Oauth framework user didn't match oauth token user

I'm trying to access a deployed appengine backend api using OAuth2.0 support from my android client. Authentication is working fine from the api explorer using the authorised email address On the android side, I'm using the credentials/account…
1
vote
1 answer

Rails 4: is it possible to extract complex authentication logic out of the controller?

Conventional Rails best practices seek to reduce the logic code in controllers as those are engineered to route and not perform complex tasks. However, if you have semi-complex authentication logic, how can you reasonably extract that logic out of…
Dan L
  • 4,319
  • 5
  • 41
  • 74
1
vote
1 answer

unable to connect to my google endpoints with my service object

I have generated my client library from my endpoints, and also passed the appropriate credential (the client ID is 100% correct) for my authenticated call to the endpoints. But I am still getting this error when I run my…
1
vote
0 answers

Interaction between service objects and application in Rails

I'm working on an application which has a lot of service objects. Usually, the job of these services is to build one or more Active Record models. To avoid tying my services to the application, I allow the user to modify the model's name. Here's an…
Alessandro Desantis
  • 14,098
  • 1
  • 26
  • 32
1
vote
4 answers

Rails service objects

I'm using service objects to abstract a stripe payment feature into it's own class. I'm using this method https://gist.github.com/ryanb/4172391 talked about by ryan bates. class Purchase def initialize(order) @order = order end def…
Saff
  • 563
  • 1
  • 10
  • 21
1
vote
1 answer

rails namespacing service objects

I just wrote a service object between the controller and the model to "mark an attendance", so now I have one object for a controller action as follows: class BookingAttendancesController def mark_attending attendance_marker =…
ecoologic
  • 10,202
  • 3
  • 62
  • 66
1
vote
1 answer

How should i transform this concern in service object?

I have a concern allowing me to give the back end user the ability to sort elements. I use it for a few different elements. The rails community seems to be pretty vocal against concern and callbacks, i'd like to have a few pointers on how to better…
0
votes
1 answer

React Soap Call - ADDING EXTRA OPERATION

Hi I used following example to make successful react soap service and client https://github.com/officer-rosmarino/node-soap-example I tried to add in a second service/operation ie add a message joiner function as well as a message splitter but I am…
0
votes
0 answers

Rails Service Object with Dry-Monad yielding early

I have a couple of service objects in my rails application where I am using Dry-Monads to influence a pattern of "success" or "failure" by using their Do Notation. However, in my main service object, upon calling a secondary service object, the main…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
1 answer

Ruby on Rails - Track API calls made to 3rd party service

I have a 3rd party API service that I am interacting with, via my Rails app, and they have quite low daily limits. Wondering what the best way to track API calls is? Database Redis In memory Other I have a service object that makes all the calls.…
michaelosmith
  • 15
  • 1
  • 7
0
votes
1 answer

What's the best way to use a service in react?

Since hooks was introduced in React, React means functional programming. But sometimes a "service"-like object is needed to solve some features. I.e.: function MyComponente() { const cache = useCache({ name: "my-component" }); …
wuarmin
  • 3,274
  • 3
  • 18
  • 31
0
votes
1 answer

Rails ApplicationService for Service Objects has both execute and call. Why?

I've inherited an app that uses a lot of Service Objects, which inherit from ApplicationService: class ApplicationService class InternalServiceError < StandardError; end include ActiveModel::Model def self.execute(*args) …
rmcsharry
  • 5,363
  • 6
  • 65
  • 108
0
votes
1 answer

undefined method `render_to_string' for #

class UpdateService def initialize(user) @user = user end def user_onboarding(request_params) file = WickedPdf.new.pdf_from_string( ApplicationController.new.render_to_string(template: 'user_agreement.pdf.erb', locals: {…
user12763413
  • 1,177
  • 3
  • 18
  • 53
0
votes
1 answer

Rails API How to add errors in exception and continue

In my Rails project I created service object which get params and save Model. I want to handle exception there when e.g. one of the params is not valid. My service object looks like that: class ModelSaver include ActiveModel::Validations …
N0ne
  • 134
  • 10