Questions tagged [service-object]
49 questions
0
votes
2 answers
Rails api how to handle service object exceptions in controller
I wanted use Service Object in my Rails API. Inside my Service Object I want to save Model and return true if saving was successful, but if saving was unsuccessful then I want to return false and send error messages. My Service Object looks like…

N0ne
- 134
- 10
0
votes
0 answers
Using ActionCable With a Service Object and Responding to a Message
Making the title for this question was extremely difficult, but essentially, I have a service object in my Rails app that creates a flow for Resume Processing. I am trying to use ActionCable to connect my frontend with my backend. The current way I…

Alex Dubov
- 13
- 4
0
votes
1 answer
How to minimize 3 ServiceObjects to 1 per 1 action
I have the Worker with an action with some code and 3 calls of Service Objects in it. 2 Service Objects for saving data to base during different states of object saving (update started, update completed). And 1 for counting the percentage of…

Vitalina
- 51
- 9
0
votes
1 answer
How to pass self from model to service object
I wanted to move def track_item_added from model into service object.
Model:
class Order < ApplicationRecord
has_many :order_items
has_many :items, through: :order_items, after_add: :track_item_added
private
def track_item_added
aft =…

Trs MTV
- 57
- 5
0
votes
1 answer
Rails 5.2 Service objects with non current user
I am trying to forward an action to another controller through the service object methodology in rails 5.2.
The create action should pass the user id for the create action but I am failing at passing that param appropriately.
Business logic is the…

Thierry
- 111
- 2
- 14
0
votes
1 answer
Are service object, transaction script and strategy design patterns the same?
I couldn't find any definition of the Service Object design pattern.
The Transaction Script design pattern
Organizes business logic by procedures where each procedure handles a single request from the presentation.
The Strategy design…

Adriano Di Giovanni
- 1,445
- 1
- 16
- 34
0
votes
0 answers
How to design the service object with view?
Foreword: maybe I misunderstand the conception of the service objects and should to design an another implementation. Thank you in advance.
I create the service object for a sms confirmations.
User must confirm his actions when:
He submits a phone…

user1201917
- 1,360
- 1
- 14
- 27
0
votes
1 answer
rails4 using helper/service and where to put it
I created this class for assembling the text based on the length of the product attributes for sharing on twitter.
My questions:
Is this the good approach to tackle the problem? If not this then what? (where should I put the class and the methods,…

Sean Magyar
- 2,360
- 1
- 25
- 57
0
votes
1 answer
rails organizing folders for service objects
I'm trying yo create a service object to extract a few methods from the product.rb AR model, but for some reason I can't autoload the new TwitterShare class. When I hit up the console and try something like Product.last.twitter_share_text I get…

Sean Magyar
- 2,360
- 1
- 25
- 57
0
votes
0 answers
Rails Associated Table Does not update
I have two models
influencers(id, first_name, ....)
influencer_authorizations(id, provider, provider_uid, oauth_token, ....)
influencers has_many influencer_authorizations
I am trying to login or Sign the Influencer
# 1. Check if the Token is…

Harsha M V
- 54,075
- 125
- 354
- 529
0
votes
1 answer
What is the goal of the tags in service settings in symfony2
In this service for an eventListener, it used the tags item:
services:
app.exception_listener:
class: AppBundle\EventListener\ExceptionListener
tags:
- { name: kernel.event_listener, event: kernel.exception }
What…

Mohamed Ben HEnda
- 2,686
- 1
- 30
- 44
0
votes
1 answer
OPOS_E_NOSERVICE after return from DllGetClassObject() in simple ATL COM OPOS Service Object
An example MSR OPOS Service Object I am writing was not initializing properly. I am adding this question to help others who run into the same problem since various searches resulted in no help whatsoever.
My question is: How can I determine what…

Richard Chambers
- 16,643
- 4
- 81
- 106
0
votes
1 answer
undefined method `insert' for RegistrationInsert:Class
I'm trying to call a method I defined in registration_insert.rb from my controller but I keep getting the following error:
undefined method `insert' for RegistrationInsert:Class
How do I correctly call the insert method?
File Structure (all…

Andrew
- 3,501
- 8
- 35
- 54
0
votes
2 answers
Disable autoincrementing id inside of ActiveRecord::Base.transaction
I have a FormObject for registration which creates a user and a lot of models for him inside create method.
def create
ActiveRecord::Base.transaction do
@user = User.create(@params[:user])
process_bonuses_for_user
…

Alex Antonov
- 14,134
- 7
- 65
- 142
0
votes
1 answer
Can I call a referring class in a service object?
I have a service object called from many different classes. Is there a way to call the referring class without passing it like this?
class Document
ServiceObject.new('Document', id)
end
Can I refer to self or super or something in ServiceObject?

t56k
- 6,769
- 9
- 52
- 115