Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completed challenge #23

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

completed challenge #23

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 3, 2016

The app I've built uses a base 65 compression algorithm to compress the id of the URL table. This is similar to Bitly, which uses a base 64 algorithm. The extra character I've added is a '-'. It will also check for duplicates in the create method of urls_controller.rb, and will display the existing shortened URL if a duplicate is entered. It will also validate user input to ensure that it's at least 3 character and contains at least one full stop character.

@ghost
Copy link
Author

ghost commented Feb 3, 2016

Also, Ubuntu 15.10 had an issue compiling Nokogiri dependencies, so I rebuilt the project with the latest version of rails.


def create
# validate that the user entered a url
if url_params[:address].size <= 3 || url_params[:address].to_s.match(/^.+\..+/).blank?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd push all of this validation logic into the model if possible or wrap it into some sort of validator class that raises errors when params don't meet a condition then you can use rescue_from to handle the exceptions/render error messaging.

@jaybobo
Copy link
Member

jaybobo commented Feb 9, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant