I'm trying to create a new Bookmark so its associated with a Topic. Everytime I try and do so, my
topic_id is nil.
Here is my bookmark_controller's create method:
def create @bookmark = Bookmark.new(params[:bookmark].permit!) #@topic = Topic.find(params[:topic_id]) @bookmark.topic_id = @topic_id @bookmark.user = current_user authorize @bookmark if @bookmark.save flash[:notice] = "Bookmark was saved." redirect_to [@topic, @bookmark] else flash[:error] = "There was an error, try it again." render :new end end
class Bookmark < ActiveRecord::Base belongs_to :topic belongs_to :user has_many :likes, dependent: :destroy end