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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:06:57+00:00 2026-06-05T23:06:57+00:00

i have this in my template <% @clients.each do |client| %> <li><%= link_to client.name,

  • 0

i have this in my template

<% @clients.each do |client| %>
<li><%= link_to client.name, :controller => "client", :action => "show", :id => client.id %></li>
<%=YAML::dump(client.lastfull)%>
<% end %>

where client looks like this:

class Client < ActiveRecord::Base
        set_table_name 'client'
        alias_attribute :id, :clientid
        set_primary_key :clientid


        has_many :jobs, :foreign_key => 'clientid', :order => 'starttime DESC'

        def lastfull
                jobs.first
        end
end

this works and this is output :

--- !ruby/object:Job attributes: jobid: "81" name: dobrak comment: "" endtime: 2012-06-20 10:15:04

But when i try to read any of the attributes i get error:

undefined method `jobid' for nil:NilClass

Job class:

class Job < ActiveRecord::Base
        attr_accessor :jobid

        set_table_name 'job'
        belongs_to :client

        has_one :status, :primary_key => 'jobstatus', :foreign_key => 'jobstatus'
end

i tried to add method jobid which return attribute and adding attr_accessor, but nothing worked for me. Any suggestions? Thank you.

Rails 2.3.5

  • 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-05T23:06:58+00:00Added an answer on June 5, 2026 at 11:06 pm

    It looks like there are clients without any jobs. What happens if you change the line to something like <%= client.lastfull.present? ? YAML::dump(client.lastfull.jobid) : 'client has no jobs' %>? You can also take a look at Object#try

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

Sidebar

Related Questions

I have this code in my django template: {%for client in clients %} {%
I have this kinda template text : Hello {#Name#}, Thanks for coming blah on
I have this code which will include template.php file from inside each of these
I have a standard template in an Html file like: <template name=cards> {{#each all_cards}}
I have a template with a static image. Each second call of this page
i have this template field inside a gridview. <asp:TemplateField ItemStyle-HorizontalAlign=Center> <ItemTemplate> <asp:ImageButton ID=ImageButton2 ImageUrl=~/images/DeleteRecord.gif
So I have this template design that is currently absolutely positioned, but I'm trying
I have code that looks like this: template<class T> class list { public: class
So I have this Xaml inside a ListBox Item Template: <ListBox.ItemTemplate> <DataTemplate> <Grid Height=22
Imagine I have a template function like this: template<typename Iterator> void myfunc(Iterator a, typename

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.