Hi.
I have 3 tables: questions, tokens, email.
When I paste question, some token (rand(9999) for example) inserting,
too. Its great. But i need paste tokens as much as I have emails in my
the database called 'Email' (i have about ~10).
I think i should use each.do for email, but how, following code doesnt
work
#controller
def create
@w = Digest::SHA1.hexdigest(rand(99999999).to_s)
@question = Question.new(params[:question])
if success = @question.save
emails = Email.find(:all) #this pasrt
emails.each do |e| #doesnt work
Token.create(:token=>@w,:is_active=>"1")
end # :(
end
end
render :json => @question.to_ext_json(:success => success)
end
How can i fix this?
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.