
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
RailsUrlShortener is a small Rails engine that provides your app with short URL functionality and IP logging capabilities - like having your own Bitly service. By default, RailsUrlShortener saves all visits to your links for future analysis or other interesting uses.
Why give your data to a third-party app when you can manage it yourself?
You can see a demo project of what you can do with this engine HERE.
Here are some of the things you can do with RailsUrlShortener:
Follow these steps to install and configure RailsUrlShortener:
gem "rails_url_shortener"
bundle install
bin/rails rails_url_shortener:install:migrations db:migrate
rails generate rails_url_shortener
Mount the engine on your app adding the next code on your config/routes.rb:
If you want to mount this on the root of your app, this should be on the bottom of your routes file.
mount RailsUrlShortener::Engine, at: "/"
And generate the short links like you want:
short_url("https://www.github.com/a-chacon/rails-url-shortener")
RailsUrlShortener::Url.generate("https://www.github.com/a-chacon/rails-url-shortener")
Then share the short link to your users or wherever you want.
Full params for the short_url helper:
short_url(url, owner: nil, key: nil, expires_at: nil, category: nil, url_options: {})
Where:
The generate
model method accepts the same parameters except for url_options
:
RailsUrlShortener::Url.generate(url, owner: nil, key: nil, expires_at: nil, category: nil)
By default, the engine saves all requests made to your short URLs. You can use this data for analytics or IP logging. To access the data:
RailsUrlShortener::Url.find_by_key("key").visits
RailsUrlShortener::Visit.all
Each Visit is associated with an Ipgeo model that contains information about the IP address:
RailsUrlShortener::Visit.first.ipgeo
When a Visit record is created, a background job is enqueued to fetch IP data from the ip-api.com service and create an Ipgeo record. This uses the free endpoint, which has a limit of 45 different IPs per minute. If you expect higher traffic, you'll need to implement an alternative solution.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)The gem is available as open source under the terms of the GPL-3.0 License.
by: a-chacon
FAQs
Unknown package
We found that rails_url_shortener demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.