-
Notifications
You must be signed in to change notification settings - Fork 40
finished #40
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
base: master
Are you sure you want to change the base?
finished #40
Conversation
| def show | ||
| if params[:id].start_with?("!") | ||
| @url = Url.find_by(:short_url => "http://localhost:3000/urls/#{params[:id]}") | ||
| @url.click_count += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this line persists the incremented count to the database.
source/app/models/url.rb
Outdated
| end | ||
|
|
||
| def shorten_url | ||
| self.short_url = "http://localhost:3000/urls/!#{(0..3).map{ rand(36).to_s(36) }.join}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its probably better to save only the random "slug" at the end. That way, we can construct the URL correctly even if this app were deployed to a production environment.
| end | ||
|
|
||
| def show | ||
| if params[:id].start_with?("!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to make the router send these two kinds of requests to two controller actions. Let me know if you'd like some guidance on that.
|
|
||
| def show | ||
| @url = Url.find(params[:id]) | ||
| url_path(@url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this line does anything.
@jaybobo