Ruby on Rails
Thursday, March 26, 2015
Hi Colin,
On Tuesday, March 24, 2015 at 3:50:37 PM UTC-3, Gm wrote:
-- Thanks for the reply.
Even if I use has many through, how can I populate the order field dinamically ?
When I do this:
def generate
(1..5).each do
questions.create(Question::SKELETON)
end
end
Thank you.
On Tuesday, March 24, 2015 at 3:50:37 PM UTC-3, Gm wrote:
Hi,I'm using habtm to create a relationship between two models:class Question < ActiveRecord::Basehas_and_belongs_to_many :examsendclass Exam < ActiveRecord::Basehas_and_belongs_to_many :questionsendAt some point I'm doing this:class Exam < ActiveRecord::Basehas_and_belongs_to_many :questionsdef generate(1..5).each doquestions.create(Question::SKELETON) endendendWhen I do that, a sql inserts a record inside questions_exams table.But this table has another column called: 'order' where I need to put some data insideHow can I populate the 'order' column inside join table ?questions_exams- question_id- exam_id- orderThanks.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b52618bd-253d-4f42-8272-7341dd4ceccf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment