I've tried to user Trailblazer to fetch some data and render it as json. Here described several problems:
- It is imposible to validate just params, without model.
Operation#validate
returns instance of operation, not value of the block. So I should use intermediate variable to return value from#process
method.
Compare:
# returns `Operation`
def process(params)
validate(params, model) do |f|
model
end
end
# returns model
def process(params)
model
end
This behaviour is very confusing.
- If I return data from
#process
method could not access operation' errors fromelse
block in controller - In the code base result of running
Operation#run
always refered asoperation
, but it is notOperation
, it is whatever returns#process