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

Code review #16

Open
wants to merge 28 commits into
base: code-review
Choose a base branch
from
Open

Code review #16

wants to merge 28 commits into from

Conversation

jaybhoyar
Copy link
Owner

No description provided.

@jaybhoyar jaybhoyar requested a review from kabir4691 February 26, 2021 17:49
before_action :find_url, only: %i[show update]

def index
urls = Url.all.order("pinned DESC, updated_at DESC")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Create a scope in Url model and use it

Copy link
Collaborator

Choose a reason for hiding this comment

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


def create
url = Url.new(url_params)
url.slug = generate_slug
Copy link
Collaborator

Choose a reason for hiding this comment

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

Controller's only job is to receive a request, fetch data from the db and send it to view.

All other business logic should go in the model, like generate_slug

@@ -1,4 +1,9 @@
Rails.application.routes.draw do

resources :urls, only: %i[index create]
get '/:slug' => "urls#show"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make routes resourceful always. In this example, use slugs/:slug instead or /:slug

Copy link
Collaborator

@kabir4691 kabir4691 left a comment

Choose a reason for hiding this comment

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

Good.

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