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

Dynamic application title #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
19 changes: 19 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
module ApplicationHelper

def application_title
controller_name = params[:controller]
action_name = params[:action]

if action_name == 'show'
if controller_name == 'companies'
"#{@company.name} Funding, Investors - Dealbook"
elsif controller_name == 'deals'
"#{@deal.company_name} raised funds from #{@deal.buyers_name} #{@deal.full_amount}"
elsif controller_name == 'investors'
investments = @investor.deals.count
companies = @investor.deals.map { |d| d.company_name }.uniq.count
"#{@investor.name} #{investments} investments in #{companies} companies"
end
else
'Dealbook - The ultimate resource for tech startups and VCs in Brazil'
end
end

def nav_link(text, link, html_options = {})
recognized = Rails.application.routes.recognize_path(link)
if recognized[:controller] == params[:controller]
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Dealbook</title>
<title><%= application_title %></title>
<%= csrf_meta_tags %>
<meta name="google-site-verification" content="eFzHwHZxstX437NOGUjFZApqyPs1jtkmTw888H6FWOQ" />
<%= favicon_link_tag %>
Expand Down