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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:09:14+00:00 2026-06-16T07:09:14+00:00

I have this strange behavior and I don’t undertand why. Here is the thing:

  • 0

I have this strange behavior and I don’t undertand why. Here is the thing:

I have this record in my payment model:

1.9.3p286 :019 > u.payment.last
  Payment Load (0.3ms)  SELECT "payments".* FROM "payments" WHERE "payments"."user_id" = 10
 => [#<Payment id: 37, bank_name: "Mercantil", plan: "Plan Uno", date: "2012-12-25", reference_number: "3452435", coupon: "", user_id: 10, created_at: "2012-12-25 21:56:12", updated_at: "2012-12-25 21:58:31", active_until: "2013-01-24">] 

As you can see, I have one record for my user: 10.

If I try to get the same information in my controller I don’t get any exception, but

@user.payment.last.active_until

is empty, the same in the view.

For example if I try this in my view:

<%= @user.payment.last.active_until %>

I didn’t get anything, is blank.

If I try this

<%= @user.payment %>

I got the same as my console

[#<Payment id: 37, bank_name: "Mercantil", plan: "Plan Uno", date: "2012-12-25", reference_number: "3452435", coupon: "", user_id: 10, created_at: "2012-12-25 21:56:12", updated_at: "2012-12-25 21:58:31", active_until: "2013-01-24">, #<Payment id: nil, bank_name: nil, plan: nil, date: nil, reference_number: nil, coupon: nil, user_id: 10, created_at: nil, updated_at: nil, active_until: nil>]

I really don’t understand what happend here. Any help please.

Thanks in advance.

PD: The user could has many payments, but I need just the last.

  • 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-16T07:09:17+00:00Added an answer on June 16, 2026 at 7:09 am

    It’s not the same as in your console. In the console you get have one record, but in the view you get two – the record that you see in the console, and another blank one.

    I’m guessing the blank one is the one that you are using for the form tag helper for the form used to create a new Payment record, but that’s also the one that last returns. Either take the one before last, or filter for saved records before you call last.

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

Sidebar

Related Questions

I have this strange behavior in my JSP page: I have two Integer variables
I have realy strange behavior. I have this code (I remove unrelated code). $(function()
I have a strange behavior with PHP system function. In this php script there
I have come across a strange behavior with Microsoft Code Contracts that I don't
I have stumbled upon a strange behavior that I don't understand. I have to
I am facing a strange behavior by CakePHP 2.1: I have a method, $this->Time->getTime();
Why this two functions have the strange behaviour of when I click on thead,
I have this strange problem. I am retrieving twitters and it works on the
I have this strange error, When I call $element_attrs = $element -> attributes(); I
i have this strange problem with the PHP function CTYPE_ALNUM if i do: PHP:

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.