Sergey
Sergey

Reputation: 49728

Get server url in Rails model without using request object?

How can I get the value equivalent to request.host without using the request object? I want to get the current url in the model without having to pass the request object from controller.

Upvotes: 0

Views: 504

Answers (1)

tagCincy
tagCincy

Reputation: 1599

No. The Model is not "aware" of the any of the request details unless the Controller informs it of thus.

The http request/response objects used in Rails are provided via Rack, which ActionController inherits from Metal, a Rack interface.

Models, in their most basic terms, are just plain Ruby Objects which inherit some db connectivity and validations functionality from ActiveRecord.

If you provide more detail into your implementation, there is probably a well established work around.

Upvotes: 1

Related Questions