Your AdSense application status: Insufficient content - ruby-on-rails

After posting my adsense code onto my Ruby on Rails app I received this message:
Insufficient content: To be approved for AdSense and show relevant ads on your site, your pages need to have enough text on them for our specialists to review and for our crawler to be able to determine what your pages are about.
The message also included these suggestions (which I think I meet with the possible exception of the 1st one and that's because it's an app not a blog):
Your content should contain complete sentences and paragraphs, not only headlines.
Ensure that your website is fully built and launched before you apply for AdSense - do not apply while your site’s still in a beta or
“under construction” phase or only consists of a website template.
Place the ad code on a live page of your website. It does not have to be the main page, but test pages that are empty except for the
AdSense ad code will not be approved.
Provide a clear navigation system for your visitors so that they can easily find all of the sections and pages of your website.
application.html.erb
<body>
<%= render 'layouts/header' %>
<div class="jumbotron">
<p class="text-center">
<%= yield :jumbotron %> <!-- this variable should be assigned in your controller action-->
</p>
</div>
<% flash.each do |name, msg| %>
<%= content_tag(:div, msg, class: "alert alert-info") %>
<% end %>
<div class="container-fluid">
<div class="container">
<div class="col-md-9">
<%= yield %> # includes pages/home (root route)
</div>
<div class="col-md-3">
<% if current_user.present? %>
<%= render 'layouts/sidebar' %> # includes _recommendations
<% end %>
</div>
</div>
</div>
</body>
_recommendations.html.erb
<div class="recommendations-padding">
<div class="ad">
<p>This is a test to see how the ads will fit here. This is a test to see how the ads will fit here. This is a test to see how the ads will fit here. This is a test to see how the ads will fit here. This is a test to see how the ads will fit here. This is a test to see how the ads will fit here. This is a test to see how the ads will fit here. This is a test to see how the ads will fit here.</p>
</div>
<div class="ad">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Recommendation 1 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-2458646218429910"
data-ad-slot="6447006986"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<div class="ad">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Recommendation #2 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-2458646218429910"
data-ad-slot="3293344589"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<div class="ad">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Recommendation 3 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-2458646218429910"
data-ad-slot="9400473387"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
home.html.erb
<% if logged_in? %>
<% if #user.habits.committed_for_today.any? %>
<div class="page-header">
<%= link_to habits_path(#habits) do %>
<h1><b>Habits</b></h1>
<% end %>
</div>
<div class="add-padding">
<%= render partial: 'habits', locals: {habits: #habits} %>
</div>
<% end %>
<% if #user.valuations.any? %>
<div class="page-header">
<%= link_to valuations_path(#valuations) do %>
<h1><b>Values</b></h1>
<% end %>
</div>
<div class="add-padding">
<%= render #valuations %>
</div>
<% end %>
<% if #user.goals.any? %>
<div class="page-header">
<%= link_to goals_path(#goals) do %>
<h1><b>Goals</b></h1>
<% end %>
</div>
<% end %>
<div class="add-padding">
<% if #user.goals.unaccomplished.any? %>
<%= render #unaccomplished_goals %>
<% end %>
<% if #user.goals.accomplished.any? %>
<div class="gold-standard">
<%= render #accomplished_goals %>
</div>
<% end %>
</div>
<% if #user.quantifieds.any? %>
<div class="page-header">
<%= link_to quantifieds_path(#quantifieds) do %>
<h1><b>Stats</b></h1>
<% end %>
</div>
<% end %>
<div class="add-padding">
<% if #user.quantifieds.averaged.any? %>
<h2><b>Averaged</b></h2>
<%= render #averaged_quantifieds %>
<% end %>
<% if #user.quantifieds.instance.any? %>
<h2><b>Instance</b></h2>
<%= render #instance_quantifieds %>
<% end %>
</div>
Do you have any suggestions on how I can get approved about Adsense?
Thank you!

I got approved to put up google ads via my blog. Once I got approved by google there they let you put ads on any site you own. Score!

Related

Display last record in erb Rails with will_paginate

I am trying to display the last instanced record from my model Tribune with this layout :
Some random tribune
Some random tribune
Last
Last recorded tribune
I am using the gem will_paginate which allow me to display 10 tribunes / per page.
The issue is that the layout is working but applied to each page.
Every 10 tribunes, one is identified as "last". Obviously, I would like to have only one tribune identified as last.
Here is my code :
<div class="wrapping">
<% #tribunes.each do |tribune| %>
<div class="container">
<div class="mouse-out-container"></div>
<div class="row">
<% if tribune == #tribunes.last
%>
<h1>Last</h1>
<div class="col-xs-12 col-md-12">
<div class="card">
<div class="card-category">Popular</div>
<div class="card-description">
<h2><%= tribune.title %></h2>
<p><%= tribune.content.split[0...25].join(' ') %>...</p>
</div>
<img class="card-user" src="https://kitt.lewagon.com/placeholder/users/tgenaitay">
<%= link_to "", tribune, :class => "card-link" %>
</div>
<% else %>
<div class="col-xs-12 col-md-12">
<div class="card">
<div class="card-category">Popular</div>
<div class="card-description">
<h2><%= tribune.title %></h2>
<p><%= tribune.content.split[0...25].join(' ') %>...</p>
</div>
<img class="card-user" src="https://kitt.lewagon.com/placeholder/users/tgenaitay">
<%= link_to "", tribune, :class => "card-link" %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="center-paginate">
<%= will_paginate #tribunes, renderer: BootstrapPagination::Rails %>
</div>
</div>
</div>
When all Goole-fu fails, we have to dig in the source code. There we find some interesting methods:
# Any will_paginate-compatible collection should have these methods:
# current_page, per_page, offset, total_entries, total_pages
#
# It can also define some of these optional methods:
# out_of_bounds?, previous_page, next_page
From these, the method next_page looks interesting, as it seems to return nil if there are no more pages.
Now we can construct the loop:
<% #tribunes.each do |tribune| %>
<% if !#tribunes.next_page && tribune == #tribunes.last %>
<!-- We're on the last page and the last tribune of that page -->
Last tribune content
<% else %>
<!-- We still have tribunes to go -->
Normal tribune content
<% end %>
<% end %>

How can I supply data to yield in my rails partial?

I'm trying to render a partial with a certain layout file. But be able to specify unique values for that specific partial. Below are the current files I have, but all that happens is the yield keywords both show the collection value. I'd like to pass a custom "title" and show the collection in the "body".
application/_news_article.html.erb
<!-- application/_news_article.html.erb -->
<% if news_article.report_text.present? %>
<div class="news_article_entry">
<div class="text-box">
<span><%= "#{news_article.published_date.strftime("%D")}" %></span> -
<%= "#{news_article.report_text}" %>
</div>
<% if news_article.impact_text.present? %>
<div class="impact-text" data-toggle="tooltip" data-placement="bottom"
title="<%= news_article.impact_text %>">Analysis</div>
<% end %>
</div>
<hr />
<% end %>
application/_news_articles.html.erb
<!-- application/_news_articles.html.erb -->
<%= render partial: "news_article", collection: articles %>
layouts/_panel_box_scrollable.html.erb
<!-- layouts/_panel_box_scrollable.html.erb -->
<div class="panel panel-default skill-evaluation-box">
<div class="skill-heading">
<div class="row">
<div class="col-xs-12">
<%= "#{yield :title}".upcase %>
</div>
</div>
</div>
<div class="skill-body scrollable">
<%= yield :body %>
</div>
</div>
schools/show.html.erb
<!-- schools/show.html.erb -->
<%= render partial: 'news_articles', layout: "layouts/panel_box_scrollable", locals: { articles: #articles } %>
Yield is where the partial will be rendered. If you want to render a title you need to pass in a title through locals or use a variable potentially on one of your models or set in the controller. In this case if you want to render a title do something like:
<%= render partial: 'news_articles', layout: "layouts/panel_box_scrollable", locals: { articles: #articles, title: 'My Title' } %>
Then in your layout do:
<div class="panel panel-default skill-evaluation-box">
<div class="skill-heading">
<div class="row">
<div class="col-xs-12">
<%= title.upcase %>
</div>
</div>
</div>
<div class="skill-body scrollable">
<%= yield %>
</div>
</div>

I'm trying to render two columns of information in my rails app

So, I have an app that is trying render 2 (or maybe more if needed) columns using a loop. It does one column and looks pretty good, but I want the option of 2 or even more. I know about "in_groups.of()", but I can't quite figure it out to work with my
<% #vendors.each do |vendor| %>
<%= link_to vendor do %>
<div class="row">
<div class="col-md-6">
<div class="card-container">
<div class="col-md-6">
<div class="card">
<%= image_tag attachment_url(vendor, :background_image), class: 'card-img-top' %>
<div class="card-block">
<h4 class="card-title"><%= vendor.Company %>. </h4>
<p class="card-text"><%= vendor.Description.html_safe.first(25) %></p>
<div class="card-standing"><strong><%= vendor.FinancialStanding %></strong></div>
</div>
</div>
</div>
</div>
</div>
</div>
<% end %>
<% end %>
Not sure why you needed this, because everything can be managed with css and html. But you can make changes like this:
<% #vendors.to_a.in_groups_of(2).each do |vendor| %> # #vendors.to_a cover AR to array
<% vendor.each do |v| %> # becuase vendor is array here.
..........your code..............
<% end %>
<% end %>

Rails 4 - Multiple yield blocks on a partial

Is it possible to have a partial using more than one yield block? I wanted to use it to implement bootstrap modal boxes on my project, kinda like this:
<div class="modal fade" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<%= yield :header %>
</div>
<div class="modal-body">
<%= yield :body %>
</div>
<div class="modal-footer">
<%= yield :footer %>
</div>
</div>
</div>
</div>
And this is more or less how I was thinking of using it
<%= render partial: "shared/modal" do %>
<% content_for :header do %>
...
<% end %> %>
<% content_for :body do %>
...
<% end %> %>
<% content_for :footer do %>
...
<% end %> %>
<% end %>
Is there a way to do this? Is this maybe a bad approach for some reason?
Through much trial and error, I think I solved this in Rails 5 but needed to insert a blank yield in my partial in order to get it to work:
_partial.html.erb
<div class="partial">
<%= yield %> <!--Does not do anything-->
<div class="header">
<%= yield :header %>
</div>
<div class="text">
<%= yield :text %>
</div>
</div>
Implemented as:
full_layout.html.erb
<%= render "partial" do %>
<% content_for :header do %>
<h1>Header content</h1>
<% end %>
<% content_for :text do %>
<p>Text content</p>
<% end %>
<% end %>
I think you have an issue with your render partial. Notice you have all of your content_for blocks within the render partial block.
<%= content_for :thing do %>
Some content
<% end %>
<%= render partial: "blah" %>
It's no problem to use multiple yield blocks in your partial. Only thing is to make sure that many is actually needed. For an example content_for sections are basically placeholders for content that could vary based on the logic of the application. So, it's totally fine to use multiple yields in one page.
You can also just run put an yield there withouth the output. This way you can also use the default block.
<div>
<% yield %>
<div class="mt-3">
<div class="text-2xl tracking-wide font-bold text-gray-900">
heading
<%= yield :heading %>
</div>
</div>
<div class="relative bg-white rounded-xl shadow-xl mb-8 min-h-28">
<%= yield %>
</div>
...

how to individualize each post? (Ruby on Rails)

On each user profile (localhost:3000/users/username), there's a listing of posts that the user has made. I implemented facebox which is a jQuery-based lightbox to display images when clicked on. This is the code that I'm using for that:
<%= image_tag post.image_url(:thumb).to_s %>
The problem is that, if a user has made 5 posts, the same image is repeated 5 times when clicked on to display in facebox.
This is my show.html.erb where I render in #posts
<% provide(:title, #user.name) %>
<div class="row">
<aside class="span4">
<section>
<h1>
<%= gravatar_for #user %>
<%= #user.name %>
</h1>
</section>
<br>
</aside>
<br>
<div class="span10">
<%= render 'follow_form' if signed_in? %>
<% if #user.posts.empty? %>
<h3>Browse</h3>
<% end %>
<% if #user.posts.any? %>
<ol class="posts">
<%= render #posts %>
</ol>
<%= will_paginate #posts %>
<% end %>
</div>
</div>
and here's the _post.html.erb
<script src="/jquery.js" type="text/javascript"></script>
<link href="/src/facebox.css" media="screen" rel="stylesheet" type="text/css"/>
<script src="/src/facebox.js" type="text/javascript"></script>
<script language="javascript">
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox()
})
</script>
<li>
<span class="content"><%= simple_format(post.content) %></span>
<% if post.image.present? %>
<%= image_tag post.image_url(:thumb).to_s %>
<br>
<% else %>
<% end %>
<span class="timestamp">
Posted <%= time_ago_in_words(post.created_at) %> ago.
</span>
</li>
The javascript in _post.html.erb is included and executed once for each post. Therefore, if the user has five posts, you are initializing facebox five times. Move the script tags out of the partial. Instead, place them in show.html.erb so that they will only execute once for the entire page.
I think facebox groups the images automatically because the all have the same "rel" attribute.
Try something like this:
<%= link_to post.image_url, :rel => "facebox-#{post.id}" do %>
<%= image_tag post.image_url(:thumb).to_s %>
<% end %>
If you're still not lucky, try to remove the rel attribute and call facebox based on a class name:
<%= link_to post.image_url, :class => "facebox" do %>
<%= image_tag post.image_url(:thumb).to_s %>
<% end %>
And the javascript:
$('a.facebox').facebox()

Resources