Skip to content

Conversation

@carakane
Copy link

def show
if params[:id].start_with?("!")
@url = Url.find_by(:short_url => "http://localhost:3000/urls/#{params[:id]}")
@url.click_count += 1
Copy link
Member

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.

end

def shorten_url
self.short_url = "http://localhost:3000/urls/!#{(0..3).map{ rand(36).to_s(36) }.join}"
Copy link
Member

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?("!")
Copy link
Member

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)
Copy link
Member

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.

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.

2 participants