i was looking around in the docs, and even though it seems there would
be a clean way to do this, i couldn’t find it.
i was hoping to take an array of objects, and create a new array of
objects, with different id’s.
like:
user_list = [user1, user2, user3, user4, user5]
and then do something in the vicinity of:
so that the only differance between the user_list and the new_user_list
is the id of each user. for somewhat reason, this isn’t working, as i’m
sure there is also a cleaner way to do this.
is there?
i was looking around in the docs, and even though it seems there would
be a clean way to do this, i couldn’t find it.
i was hoping to take an array of objects, and create a new array of
objects, with different id’s.
like:
user_list = [user1, user2, user3, user4, user5]
and then do something in the vicinity of:
so that the only differance between the user_list and the new_user_list
is the id of each user. for somewhat reason, this isn’t working, as i’m
sure there is also a cleaner way to do this.
is there?
thanks ahead of time,
harp
Hey Harp,
I have not tried this out yet, but the map method is handy for this sort
of thing.
something like:
new_user_list = user_list.map do {|user| User.create(user.attributes)}
i was looking around in the docs, and even though it seems there would
be a clean way to do this, i couldn’t find it.
i was hoping to take an array of objects, and create a new array of
objects, with different id’s.
like:
user_list = [user1, user2, user3, user4, user5]
and then do something in the vicinity of:
so that the only differance between the user_list and the new_user_list
is the id of each user. for somewhat reason, this isn’t working, as i’m
sure there is also a cleaner way to do this.
is there?
thanks ahead of time,
harp
Hey Harp,
I have not tried this out yet, but the map method is handy for this sort
of thing.
something like:
new_user_list = user_list.map do {|user| User.create(user.attributes)}
That should work.
…ok, after trying a little after writing this post, the problem turns
out to be becuase of a file column issue - - not the create/attribute
method. for somewhat reason, the create method does not accept a
file_column attribute (needs multipart enctype). to somehow escape this,
i was wondering whether this could be done simply by an sql snippit or
something…
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.