fidelisrafael / nifty_services Goto Github PK
View Code? Open in Web Editor NEWThe dead simple services object oriented layer for Ruby applications to give robustness and cohesion back to your code.
License: MIT License
The dead simple services object oriented layer for Ruby applications to give robustness and cohesion back to your code.
License: MIT License
Why do not set a default log in log/deafult.log
?
Before merged something, i'd like rebase all commits to keep history readable.
what you think?
As I see here, it should be an unprocessable_entity
error instead of not_found
, because it is a create action and doesn't make sense to check if user is not found to create it.
https://github.com/fidelisrafael/nifty_services#alien-invalid-user-
You must have the following keys setup up in your locales files:
nifty_services:
users:
not_found: "Invalid or not found user"
ip_temporarily_blocked: "This IP is temporarily blocked from creating records"
# note: posts is the key return in `record_error_key` service method
posts:
user_cant_create: "User cant create this record"
If you try to create a post for a invalid user, such as:
# PostCreateService.new(user, options)
service = PostCreateService.new(nil, options)
service.execute
service.success? # false
service.response_status # :not_found
service.response_status_code # 404
service.errors # ["Invalid or not found user"]
Hi Fidelis,
I spent some time reading all documentation and I think it is confuse sometimes, because there is too much information on the same page and I need to keep scrolling to find something I have read.
What do you think to move everything to Wiki pages and just let the summary on README?
I was thinking that constant WHITELIST_ATTRIBUTES
could be a Class Method like record_type
For example, Instead of:
WHITELIST_ATTRIBUTES = [:title, :content]
def record_allowed_attributes
WHITELIST_ATTRIBUTES
end
Could be:
whitelist_attributes :title, :content
What do you think?
Should you create this helper method in a generic helper which could be accessed from anywhere?
def generic_response_for_service(service, success_response)
default_response = {
status: service.response_status,
status_code: service.response_status_code,
success: service.success?
}
if service.success?
response = success_response
else
response = {
error: true,
errors: service.errors
}
end
default_response.merge(response)
end
I like the idea of have this method in BaseController, so I can use from every controller by ihneritance, what do you think?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.