Your change from . to :: is a red herring. The method call semantics
of . and :: are the same. The error means that your CreateUri class is
not being loaded. Check the way it is loaded (by Rails autoloading, by
a require statement, etc).
Also, I would have structured the url creation class differently.
First, CreateUri is a poor class name because it is too generic.
Second, passing an integer (the vehicle id) would require the
CreateUri class to know far too much about what that integer
represents, thus coupling it conceptually to the Vehicle class. These
problems are apparent in the need for the awkward method name
“bit_ly_for_vehicle”. The Bitly url generator should accept a url and
return a url, as this is the interface provided by the service itself
(bit.ly’s API).
Given that the Bitly API requires authentication, I would prefer
something like:
Bitly.new(username, api_token).shorten(url_for(@vehicle)).short_url
“Shorten the url for the vehicle” reveals the code’s intention nicely.
In fact, and speaking of reuse, this is precisely what the Bitly gem
provides (GitHub - philnash/bitly: 🗜 A Ruby wrapper for the bit.ly API).
This does not address performance and reliability concerns with the
network, the Bitly service and etc., but it is at least a good start.
Also, do note that this will require url_for in your model. Google
should tell you how to make this happen.
On Jan 5, 1:29Â am, Quee WM [email protected] wrote:
 end
NameError (uninitialized constant Vehicle::CreateUri):
 app/models/vehicle.rb:22:in update_bit_ly_url'  app/controllers/vehicles_controller.rb:46:in
create’
Any ideas?
Posted viahttp://www.ruby-forum.com/.
Rein H.
http://reinh.com | http://reductivelabs.com