Forum: Ruby on Rails Create 50 objects and show only them

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C1e5844d1c5381e0d2085c2240e38ada?d=identicon&s=25 Medwedj Potapow (medwedj)
on 2008-11-04 23:09
Hello all!

Situation: user has a possibility to create variable amount number of
objects. The number choses user himself. After creating user wants to
see all just created objects. And only them. Not the rest.
How can it be done?

I put all created object in an array but what then? Redirecting to the
"index" shows all the objects in the table and my variable
@created_objects is after redirection no longer available.

Thanx for help!
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2008-11-04 23:27
You could store the ids in an array in the session. Note: Don't store
the entire objects in the session just the id columns so you can  look
them back up in after the redirect.

Medwedj Potapow wrote:
> Hello all!
>
> Situation: user has a possibility to create variable amount number of
> objects. The number choses user himself. After creating user wants to
> see all just created objects. And only them. Not the rest.
> How can it be done?
>
> I put all created object in an array but what then? Redirecting to the
> "index" shows all the objects in the table and my variable
> @created_objects is after redirection no longer available.
>
> Thanx for help!
C1e5844d1c5381e0d2085c2240e38ada?d=identicon&s=25 Medwedj Potapow (medwedj)
on 2008-11-07 18:10
I solved the problem myself!

The point is: while creating Istored all the object in an array. After
saving I did:

respond_to do |format|
  format.html { render :action => 'last_created' }
end

An in the view "last_created" I go over the entire array and show all
the objects in a table.
This topic is locked and can not be replied to.