add a associated value in ruby on rails from independent page
问题 im beginner of ruby on rails. i have brand - products list. Brand, class Brand < ApplicationRecord has_many :products, dependent: :destroy validates :title, presence: true, length: { minimum: 2 } end Product, class Product < ApplicationRecord belongs_to :brand end products.controller class ProductsController < ApplicationController skip_before_action :verify_authenticity_token def edit @product = Product.find(params[:id]) end def new @product = Product.new end def update @brand = Brand.find