-
Notifications
You must be signed in to change notification settings - Fork 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
Complete Release 3 #38
base: master
Are you sure you want to change the base?
Conversation
@lnestor cool! i'm loving the early specs and TDD approach by the way. |
@jaybobo I've done all the main tasks, so I'm tagging you. I'll go ahead and work on the extra credit part. |
source/app/views/urls/index.html.erb
Outdated
|
||
<ul> | ||
<% @urls.each do |url| %> | ||
<li><%= "0.0.0.0:3000/urls/#{url.id} ====> #{url.long_url} (clicked #{url.click_count} times)" %></li> |
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.
Your routes file has a :urls
resource with a :show
action, so it should generate route helper methods for you. The name of it is kinda unfortunate in this case:
I think url_url(url)
should output something like "0.0.0.0:3000/urls/#{url.id}"
here. (and will remain correct in non-development environments)
I don't see implementation for these URL validations yet:
|
source/app/models/url.rb
Outdated
private | ||
|
||
def reset_click_count | ||
self.click_count = 0 |
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.
If the migration put a default of zero in the db, ActiveRecord would respect that when you make new instances of this class.
source/app/models/url.rb
Outdated
|
||
def long_url_is_reachable | ||
begin | ||
response = HTTParty.get(long_url, timeout: 2) |
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.
default timeout == ain't nobody got time for that 👍
source/app/models/url.rb
Outdated
class Url < ActiveRecord::Base | ||
before_create :reset_click_count | ||
|
||
validates :long_url, presence: true, format: { with: /http(|s):\/\/.+/ } |
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 could nitpick this format
regexp, but I'm not sure if it is needed. Is the URI::regexp
matching sufficient?
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.
You're right - this is leftover from before I implemented the URI matching.
@jaybobo I haven't completed all parts, but I figured I'll commit each time I finish a step. I'll ping you when it is completely done too.