Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:56:32+00:00 2026-06-15T10:56:32+00:00

I have a partial I am trying to load though a create.js.erb, problem is

  • 0

I have a partial I am trying to load though a create.js.erb, problem is that it loads fine when I can the partial from the view, but when I try to call it in the ajax action I get a NoMethodError for each https://gist.github.com/4191176

hashtag.rb

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

hashtags_controller

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

create.js.erb

$(".live-votes").slideDown(2222).prepend("<%= escape_javascript(render(:partial => 'shared/vote_tweets', :object => @random_hashtags)) %>")

_vote_tweet partial

<% @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 %>

error

NoMethodError in Hashtags#create

Showing ./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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:56:33+00:00Added an answer on June 15, 2026 at 10:56 am

    Yes, :object => @random_hashtags is NOT the same as giving @random_hashtags a value, without reading in the manual I think that is saying that you can use a variable vote_tweet in your partial “_vote_tveet” (which in that case has the value from @random_hashtags which MUST have been initiated). So if you still are using @random_hashtags in your partial and giving it a value in the controller, then you should skip :object => @random_hashtags in the line in create.js.erb

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok I have this problem I'm trying to use Jquery to load a partial
I have a partial view that is shared between two controllers and I'm trying
I have a view that has some jQuery to load a partial view (via
I am trying to create a view that loads only for mobile sites. Apparently
I have a partial view that I want to basically take care of itself
I have a partial view (UserControl) that implements a simple pager in my Asp.Net
I have a view that contains a partial view containing a WebGrid that pages
i am trying to load images from the northwind database (categories table, images that
I am currently having the problem that I have a (partial) program that is
I have this code, but can't get it all working. I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.