我是一名初學者,我目前正在關注Mackenzie Child's Portfolio + Blog Rails Youtube教程在Heroku上部署網站。你可以找到鏈接到教程這裏:https://www.youtube.com/watch?v=62PQUaDhgqw&t=14s語法錯誤彈出試圖添加友好的ID寶石
我想補充的友好ID寶石,但我遇到了這個問題,在我的終端:
Ivys-MacBook-Pro:portfolio ivychen$ Post.find_each(&:save)
-bash: syntax error near unexpected token `&'
我不知道如何解決它。我想我可能還沒有正確格式化我post.rb的線條,讓它們在這裏,如果你想看看:
class Post < ApplicationRecord
has_attached_file :image, styles: { large: "600x600>", medium: "300x300>", thumb: "150x150#"}
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
extend FriendlyId
friendly_id :title, use: :slugged
end
這是我已經把我的post_controller.rb:
def find_post
@post = Post.friendly.find(params[:id])
end
這可能是一個簡單的修復,但我只是不知道該怎麼做!謝謝!任何幫助將不勝感激。
您suntax似乎是錯誤的,我會試着去'Post.find_each {|文章| post.save! }' – tomtomtom
我明白了!謝謝! –