I’m working on a rails application and I’m trying to access this variable and I keep getting undefined method errors, etc.
In my controller, I am doing:
@application = Application.find(params[:id])
@curr_app_id = @application.application_field.last(1)
puts @curr_app_id
and it prints out
#<ApplicationField:0x56678b8>
What type of variable is this, and how can i access it’s ID?
I did some investigation in my IRB console …
Same output, different classes!
Giving an integer to the
lastmethod (even if you give 1) results in a Array: Class Array (Ruby 1.9.3) here.You should use last without parameter: