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

Small fixes #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ So, here the story begins...
- Rest a little and feel proud of yourself that you've done your first open-source contribution!

### Want to join us?
[Join us in slack!](https://join.slack.com/t/findopensourc-prt7834/shared_invite/enQtNzQ5MTIyMzU4NTgzLTg5MGYwMTdhYWIzMGE4ZDc5ZWRlMWI1YTEyNjAzN2ZjNTc4NmMzMjI2NmYzM2U5NTEyMDI2ZTk0MGVhNWU1ZDk)
Join us in Slack and let us know what you would like to work on (even if there's no issue for that!):
[Join us in slack!](https://join.slack.com/t/open-source-mentor/shared_invite/enQtODAwOTkzODcxOTA1LTllODUyMzcxZTk4MmZjZWFhM2IxOTUzYTU5N2UwNmFlNDhmY2MxOGM0NjA3OTBlMzIxNTYzNGJiYzU0ODQzZjE)

26 changes: 9 additions & 17 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ class ProjectsController < ApplicationController
before_action :authenticate_user!
before_action :authorize!, only: %i[edit update destroy]
before_action :current_project, only: %i[show edit update destroy]
# before_action :repo, only: %i[edit update destroy]
# before_action :repos, only: %i[edit update destroy]

def index
@projects = Project.all
Expand All @@ -17,36 +15,30 @@ def show; end

def new
@project = Project.new
@repos = repos
@repo = repo
fetch_repos
fetch_repo
end

def repos
def fetch_repos
@client = Octokit::Client.new

Choose a reason for hiding this comment

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

Can we move all these 3 lines in 1 ServiceObject?

For example in the end we would get the following:

class FetchRepo
def call
# client / github user fetched
client.repos(@github_user.login, query: { type: 'owner', sort: 'asc' })
end
end

And in the controller:

@repos = FetchRepos.call

What do you think about it?

Copy link
Contributor Author

@oxanayoxana oxanayoxana Dec 15, 2019

Choose a reason for hiding this comment

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

@deny7ko look, I've managed to do that! ) But why the changes don't show up hmm...

@github_user = @client.user(current_user.nickname)
@repos = @client.repos(@github_user.login, query: { type: 'owner', sort: 'asc' })
end

def repo
@repos.map(&:name)
def fetch_repo
@repo = @repos.map(&:name)

Choose a reason for hiding this comment

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

This method returns an array of names, right?

Why does it called in singular fetch_repo?

end

def edit
current_project
@repos = repos
@repo = repo
fetch_repos
fetch_repo
end

def repo
@repos.map {|r| r.name }
end

def edit; end

def create
@project = Project.new(project_params)

Choose a reason for hiding this comment

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

Some variables are initalized inside the method, some of them outside?
Keep one style:

@project =
@repos =

Instead of doing a mix

@project =
fetch_repos

It will make it easier to read your code

@repos = repos
@repo = repo
fetch_repos
fetch_repo

respond_to do |format|
if @project.save
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<% if user_signed_in? %>
<%= link_to 'Sign Out', destroy_user_session_path, method: :delete, class: "nav-link" %>
<% else %>
<%= link_to "Sign in with Github", user_github_omniauth_authorize_path, class: "nav-link" %>
<%= link_to "Sign in with Github", root_path, class: "nav-link" %>
<% end %>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<main role="main">
<main role="main">
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">Find OpenSource Mentor</h1>
Expand Down