2012-12-16 6 views
0

내가 통합하고 여러 가지 모델 (아이디어, 질문 등) 콘솔에서 하나 개의 주제 모델에 다른 모델로 한 모델에서 필드와 나는 이런 식으로 뭔가가 작동하지 않을 수 있습니다 생각 :가져 오기

Question.find_each do |q| 
    t = Topic.new 
    t.create(:title=q.title, :description=q.description, :kind=”Question”) 
end 

그러나 누군가가이 같은 모델간에 데이터를 전송하고 그것을 할 수있는 "권리"방법이 있다면 시도했는지 궁금

SyntaxError: (irb):24: syntax error, unexpected tIDENTIFIER, expecting ')' 
t.create(:title=q.title,:description=q.description,:kind='question') 

: 나는 오류를 받고 있어요.

[편집] 이 작동 :

Question.find_each do |q| 
@qt=q.title 
@qd=q.description 
@q=‘Question’ 
@ca=q.created_at 
@ui=q.user.id 
@uvt=q.user_votes_total 
Topic.create!({:title => @qt, :description => [@qd], :kind => @q, :created_at=>@ca, :user_id=>@ui, :user_votes_total=>@uvt }) 
end 

답변

1

=>

t.create(:title => q.title, :description => q.description, :kind => 'Question') 
+0

감사와 = 교체! 질문에 작동하는 최종 버전을 게시하여 뇌가 작동을 멈췄을 때 다른 사람이 대답을 찾도록했습니다. :) –

관련 문제