无法在rails中使用用户关联

时间:2015-09-23 10:03:11

标签: ruby-on-rails ruby

我一直在努力让协会工作。用户SELECT count(`table1`.`event_id`) AS t1_event_count FROM `table1` LEFT JOIN `table2` ON `table2`.`event_id` = `table1`.`event_id` WHERE `table2`.`time_name` = 'morning' 和广告系列has_many :campaigns

但是当我尝试制作新的广告系列时,它会给我一个错误,说广告系列是一种无效的方法

belongs_to :user

我已经完成了所有user_id迁移和填充

def index
    @campaigns = Campaign.all.order("created_at DESC")
  end

  # GET /campaigns/1
  # GET /campaigns/1.json
  def show
  end

  # GET /campaigns/new
  def new
    @campaign = current_user.campaigns.build
  end

  # GET /campaigns/1/edit
  def edit
  end

  # POST /campaigns
  # POST /campaigns.json
    def create
    @campaign = current_user.campaigns.new(campaign_params)

    if @campaign.save
      redirect_to @campaign
    else
      render 'new'
    end

错误消息:未定义的方法`广告系列'对于#

0 个答案:

没有答案