top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Compact Nested Iterator in Rails?

+1 vote
207 views

Is there a more compact way to do a nested each ?

value.each do |x|
 x.data.each do |y|
 puts 'x: ' + x + ' y: ' + y
 end
end

That is can this be reduced to one or two lines?

posted Jul 15, 2014 by Deepak Dasgupta

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

Recently I have been reading about form objects and have been wondering its use in 1 to many association. Let's say I have a model of project with many tasks and the user edits the project along with the tasks in one big form.

Is nested attributes using cocoon gem better suited than using reform/virtus or other form objects? Any examples of using form objects in this context?

0 votes

I was reading the docs for primary key on postgresql and I saw that there was a way to add a custom stored procedure that returns a UUID. There is a test case as well that uses a custom uuid generator

https://github.com/rails/rails/blob/650ea5e5cf50d8a**********cf1762922d330a8/activerecord/test/cases/adapters/postgresql/uuid_test.rb#L193

But I was not sure how to to implement this myself. Like in the test case where do I place my_uuid_generator() and how to implement it in my rails application?

+1 vote

Am trying to send email with yahoo mail but it is not working but, with gmail works fine can someone correct me if anything is wrong in my smtp.

    production:
 :address: smtp.yahoo.mail.com
 :port: 587
 :user_name: test@yahoo.com
 :password: test
 :authentication: plain
 :enable_starttls_auto: true
 :domain : test.com
...