You are actively loading Books
from the database, so AREL tries to map your select statement to the model. In this case, it maps the date to the borrow_date
attribute and converts it into a Date object. The original formatting you selected is then no longer relevant as it was parsed to an object which has its own rules for printing the date.
Your second select works since there probably is no attribute of that name on your Book
model, so it cannot be mapped to a specific type, so plain String
is used.
You could simply add a function like formatted_borrow_date
to your model or use a helper to have it format the borrow_date
using ruby methods to avoid the hardcoded SQL and date formatting.