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

  • SEARCH
  • Home
  • 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 6790643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:44:57+00:00 2026-05-26T17:44:57+00:00

I feel like a moron asking this, but since I’m a new to developing,

  • 0

I feel like a moron asking this, but since I’m a new to developing, and I’ve been sitting here for an hour making something so simple work, I need to ask.

I want to show each Widget, but I keeping getting:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each

I tried using <%= debug @widgets %> and <%= @widgets.inspect %>, but nothing shows in my command prompt or browser.

I was trying to copy the each do statement on http://guides.rubyonrails.org/layouts_and_rendering.html

In my controller, called Pages Controller, I have:

def widgets_to_show
  @widgets = Widget.all
end 

In my view (pages#widgets_to_show), I have:

<% @widgets.each do |widget| %>
  <%= widget.title %>
<% end %>
  • I have a widget model
  • I also have values in the widgets table
  • and I have a title field, so I’m not sure what I’m doing wrong

I’m trying to display it on a page that uses the High Voltage gem (https://github.com/thoughtbot/high_voltage) if that makes a difference.

  • 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-05-26T17:44:58+00:00Added an answer on May 26, 2026 at 5:44 pm

    As @DaveNewton suggested try accessing the widget from your console (not irb). Do the following from your terminal

    # from your rails project dir
    $ rails c
    $ w = Widgets.all
    $ puts w
    $ w.each { |n| puts n.title }
    

    If all of that works then we need more info to figure out what the problem is.

    Edit:

    My guess is that it has something to do with using high voltage on the same page. It’s a gem for creating static pages so maybe that’s interfering with showing your widgets – since what you’re doing is something dynamic.

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

Sidebar

Related Questions

I feel like I should know this, but I haven't been able to figure
I feel like an idiot for asking this but what would a regular expression
I feel like I should know this but I've been stumped for hours now
I feel like this is a simple question, but I am still relatively new
I feel like this question ought to have been covered, but I can't seem
I feel like this must have been asked, but I'm unable to find it
I feel like a moron posting such simple questions on here, but the knowledge
I feel like I'm missing something here, but I have this datagrid which when
I feel like a fool, but here goes: public interface IHasErrorController{ ErrorController ErrorController {
I feel like I'm re-inventing the wheel here, but I need to find a

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.