Hi there,
I have the collection with items "name", "surname", "sequence". When
I'm saving next user to my collection, I need to get the highest value
of "sequence" in my collection, this value increment and save to new
user... but I don't know, how to get the highest value stored in
collection...
But obviously I'm getting error message about undefined local variable
sequence.
I am trying this problem to solve following:
--
high = Users.find(:order => 'sequence_at DESC', :limit => 1)
unless high.sequence.nil? || high.sequence == 0
save_seq += 1
else
save_seq = 1
end
@user_new = Users.new(:name => params[:name], :sequence => save_seq)
I will be very glad for every help!
Thanks, Manny
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment