我提出了申请,我似乎与我的协会存在一些问题。 我有:
class User < ActiveRecord::Base
acts_as_authentic
has_many :questions, :dependent => :destroy
has_many :sites , :dependent => :destroy
end
问 题
class Question < ActiveRecord::Base
has_many :sites, :dependent => :destroy
has_many :notes, :through => :sites
belongs_to :user
end
地点(视之为问题的答复)
class Site < ActiveRecord::Base
acts_as_voteable :vote_counter => true
belongs_to :question
belongs_to :user
has_many :notes, :dependent => :destroy
has_many :likes, :dependent => :destroy
has_attached_file :photo, :styles => { :small => "250x250>" }
validates_presence_of :name, :description
end
当一个站点(电塔)创建时,我成功地将问题发到现场桌旁,但我无法说明如何也通过用户。 这里是我的场址
def create
@question = Question.find(params[:question_id])
@site = @question.sites.create!(params[:site])
respond_to do |format|
format.html { redirect_to(@question) }
format.js
end
end