Last active
December 12, 2015 01:39
-
-
Save kibaekr/4692816 to your computer and use it in GitHub Desktop.
www
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def achievements | |
achieve = [] | |
admin_for = memberships.where(admin: true) | |
achieve << 'admin' if admin_for.any? | |
achieve << 'paid_admin' if admin_for.detect { |m| m.account.invoices.paid.any? } | |
#achieve << 'www' if domain_includes?("www") | |
achieve.join(',') | |
end | |
def domain_includes?(string) | |
#accounts.each { |account| account.watched_domains.each {|domain| domain.url }}.any? {|url| url.include?(string)} | |
accounts.each do |account| | |
account.watched_domains.each do |domain| | |
if domain.url.include?("www") | |
return true | |
else | |
return false | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@watched_domain = @current_account.watched_domains.build(params[:watched_domain]) | |
if @watched_domain.include?("www") | |
@current_account.users.each { |user| user.achievements << 'www'} | |
end | |
respond_to do |format| | |
if @watched_domain.save | |
format.html { redirect_to @watched_domain, flash: { success: 'Domain was successfully created. Now try adding some keywords.' } } | |
format.json { render json: @watched_domain, status: :created, location: watched_domains_path } | |
else | |
format.html { redirect_to watched_domains_path, flash: { error: @watched_domain.errors[:base].join("<br />") } } | |
format.json { render json: @watched_domain.errors, status: :unprocessable_entity } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
domain_includes? method should be