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#validatereturns instance of operation, not value of the block. So I should use intermediate variable to return value from#processmethod.
Compare:
# returns `Operation`
def process(params)
validate(params, model) do |f|
model
end
end# returns model
def process(params)
model
endThis behaviour is very confusing.
- If I return data from
#processmethod could not access operation' errors fromelseblock in controller - In the code base result of running
Operation#runalways refered asoperation, but it is notOperation, it is whatever returns#process