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 5999665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:35:04+00:00 2026-05-23T00:35:04+00:00

I have checkedout the docs on this but I am still a bit confused.

  • 0

I have checkedout the docs on this but I am still a bit confused. My goal is to return the content field on @mom. But it fails with undefined method `content’. and @goals works. What am I missing about @mom and how can I get that to work?

project_controller.rb

def show
  @project = Project.find(params[:id])
  @goals = @project.projectgoals.find(:first, :order => "created_at DESC")
  @mom = @project.projectgoals.order(:created_at => "DESC").limit(1).all
end

Show.html.erb

<b>Name: </b><%= @project.name %><br/>
<b>Goals: </b><%= @goals.content %><br/>
<b>Goals: </b><%= @mom.content %>
<br/>
<%= debug @mom %>

Models

class Projectgoal < ActiveRecord::Base
  attr_accessible :content, :project_id
  belongs_to :projects
end

class Project < ActiveRecord::Base
  attr_accessible :name
  has_many :projectgoals
  has_many :projectstatuses
end
  • 1 1 Answer
  • 4 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-23T00:35:04+00:00Added an answer on May 23, 2026 at 12:35 am

    Try this in your controller instead (it’ll return one record rather than an array with one record):

    @mom = @project.projectgoals.order("created_at DESC").first
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have checked out this question, but the answer is very large for me:
I have checked out code from a svn repository and started making changes. But
Seems like this should be super-simple but looking around for a simple (or half-way
Let's say I have checkedout a project via SVN, then I right clicked the
I have checked out a maven project which gives me a Return code is:
I'm trying to write a little greasemonkey script/bookmarklet/what have you for Google Docs. The
I have checked out http://rubyforge.org/projects/lame-encoder/ but the problem is it isn't documented(i don't even
So I have a table that contains a column with a button. When this
I have a SVN project at work that looks like this: Repository project |--
I have a problem with python and dbus. I checked out the developer docs

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.