0
我要種子單頁,有許多文件和訪問路線,如今我不喜歡這樣寫道:導軌 - 從seedfile
PageFile.create!([
{ file_body: seedfile('/file1.jpg'), page_id: Page.where(path: 'my_page').take.id }
但我認爲這是不靈活,我想它取決於通過routes.rb中的數據:
get 'my_page' => 'pages#my_page', as: :my_page
我想:
page_id: Page.where(path: my_page_path) }
page_id: Page.where(path: :my_page_path) }
page_id: Page.where(path: Page.select(:my_page_path)) }
他們全部返回錯誤或爲零。我究竟做錯了什麼?