Skip to content

Instantly share code, notes, and snippets.

@thebusiness11
Created December 2, 2012 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebusiness11/4191176 to your computer and use it in GitHub Desktop.
Save thebusiness11/4191176 to your computer and use it in GitHub Desktop.
Ajax
<% @random_hashtags.each do |hashtag| %>
<div class="span4 twitter-spans-v1">
<div id="tweet-block-v1" class="hashtag-tweet-database-container">
<div class="tweet-block-border-v1">
<div class="tweet-block-spacing-v1">
<div class="twitter-block-author-v1">
<a class="twitter-block-user-v1" target="_blank" href="https://twitter.com/<%= hashtag.from_user %>">
<span class="twitter-author-image-v1"><img alt="" class="twitter-author-image-photo-v1" src="<%= hashtag.profile_image_url %>"></span>
<span class="twitter-author-name-v1"><%= hashtag.from_user_name %></span>
<span class="twitter-author-nickname-v1">@<%= hashtag.from_user %></span>
</a>
<iframe class="twitter-follow-button-v1" scrolling="no" frameborder="0" src="//platform.twitter.com/widgets/follow_button.html#align=right&button=grey&screen_name=<%= hashtag.from_user %>&show_count=false&show_screen_name=false&lang=en" allowtransparency="true">
</iframe>
</div>
<div class="twitter-text-container-v1">
<p class="twitter-text-field-v1">
<%= hashtag.text %>
</p>
</div>
<div class="twitter-footer-v1">
<a class="twitter-view-details-v1" target="_blank" href="https://twitter.com/<%= hashtag.from_user %>/statuses/<%= hashtag.tweet_id %>">
<span class="tweet-date-v1"><%= hashtag.created_at.strftime("%d %b %Y") %></span>
</a>
<span class="twitter-vote-button-v1"><a href="#" class="btn btn-mini btn-primary">#WINNING</a>
</span>
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
<ul class="twitter-intent-ul-v1">
<li class="twitter-intent-li-v1"><a href="https://twitter.com/intent/tweet?in_reply_to=<%= hashtag.tweet_id %>" class="twitter-intent-tweet" title="Reply"></a></li>
<li class="twitter-intent-li-v1"><a href="https://twitter.com/intent/retweet?tweet_id=<%= hashtag.tweet_id %>" class="twitter-intent-retweet" title="Retweet"></a></li>
<li class="twitter-intent-li-v1"><a href="https://twitter.com/intent/favorite?tweet_id=<%= hashtag.tweet_id %>" class="twitter-intent-favorite" title="Favorite"></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<% end %>
$(".live-votes").slideDown(2222).prepend("<%= escape_javascript(render(:partial => 'shared/vote_tweets', :object => @random_hashtags)) %>")
NoMethodError in Hashtags#create
Showing /Users/lancevelasco/Development/tweetvstweet/app/views/shared/_vote_tweets.html.erb where line #1 raised:
undefined method `each' for nil:NilClass
Extracted source (around line #1):
1: <% @random_hashtags.each do |hashtag| %>
2: <div class="span4 twitter-spans-v1">
3: <div id="tweet-block-v1" class="hashtag-tweet-database-container">
4: <div class="tweet-block-border-v1">
Trace of template inclusion: app/views/hashtags/create.js.erb
class HashtagsController < ApplicationController
def home
end
def vote
@random_hashtags = Hashtag.order("RANDOM()").limit(4)
end
def show
end
def index
end
def create
Hashtag.pull_hashtag(params[:hashtag])
respond_to do |format|
format.html { redirect_to vote_path }
format.js
end
end
end
class Hashtag < ActiveRecord::Base
attr_accessible :text, :profile_image_url, :from_user, :created_at, :tweet_id, :hashtag, :from_user_name
def self.pull_hashtag(hashtag)
hashtag_scrubbed = hashtag
Twitter.search("%#{hashtag}", :lang => "en", :count => 100, :result_type => "mixed").results.map do |tweet|
unless exists?(tweet_id: tweet.id)
create!(
tweet_id: tweet.id,
text: tweet.text,
profile_image_url: tweet.user.profile_image_url,
from_user: tweet.from_user,
from_user_name: tweet.user.name,
created_at: tweet.created_at,
hashtag: hashtag
)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment