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

Fix generating contact pages #45

Merged
merged 2 commits into from
Jan 11, 2017
Merged

Fix generating contact pages #45

merged 2 commits into from
Jan 11, 2017

Conversation

bfcoder
Copy link
Contributor

@bfcoder bfcoder commented Jan 11, 2017

Remove class variables.
Use only one instance of StaffInfo.

This fixes the contact page to contain contact info for only the given course. Also fixes so it works with -m in the task.

Remove class variables.
Use only one instance of StaffInfo.
Copy link

@conradbeach conradbeach left a comment

Choose a reason for hiding this comment

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

I had one suggestion but the code and functionality looks good.

body,
"<li>Home Page: #{opts[:home_page]}</li>",
opts[:home_page],
)
Copy link

@conradbeach conradbeach Jan 11, 2017

Choose a reason for hiding this comment

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

Lines 68-84 are doing the same thing for each option. Could we dry it up like this?

[:email, :phone, :office_hours, :office_address, :home_page].each do |key|
  append_str body, "<li>#{sym_to_title(key)}: #{opts[key]}</li>", opts[key]
end

The sym_to_title method could look something like this.

def sym_to_title(symbol)
  symbol.to_s.gsub("_", " ").split(/\W/).map(&:capitalize).join(" ")
end

I feel like this would make it easier to read as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I like that, but your sym_to_title isn't very easy to read. So I'll use Activesupport instead.

Choose a reason for hiding this comment

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

Ah, I didn't realize we had ActiveSupport. That's definitely a better choice than using what I wrote.

Copy link

@conradbeach conradbeach left a comment

Choose a reason for hiding this comment

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

Looks great.

@bfcoder bfcoder merged commit af6ec73 into master Jan 11, 2017
@bfcoder bfcoder deleted the bf-fix-staff-info branch January 11, 2017 20:13
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.

None yet

2 participants