คุณสามารถแก้ไขไฟล์ .erb โดยตรงจาก Heroku Console ได้หรือไม่

ฉันสงสัยว่าสิ่งนี้เป็นไปไม่ได้เนื่องจากการควบคุมเวอร์ชัน แต่ฉันสงสัยว่ามีวิธีดูโค้ดในไฟล์ .html.erb โดยตรงหรือไม่ และแก้ไขให้แก้ไขตัวพิมพ์ผิดเล็กน้อย โดยไม่ต้องปรับใช้ทั้งแอปใหม่

ฉันเปิดคอนโซล Heroku แล้วพิมพ์ Dir.chdir "app/views/pages" นั่นนำฉันไปยังโฟลเดอร์ที่ถูกต้องในไดเร็กทอรี

√ _testApps/[app_name] % heroku console  
irb(main):001:0> Dir.chdir "app/views/pages"
=> 0

จากนั้นฉันสามารถดำเนินการ Dir.glob("*.erb") เพื่อดูรายการไฟล์ทั้งหมดในไดเรกทอรีนั้นที่มีนามสกุลนั้นได้

irb(main):002:0> Dir.glob("*.erb")
=> ["sitemap.html.erb", "about.html.erb", "home.html.erb", "guide.html.erb", 
"media_kit.html.erb", "social.html.erb", "terms_of_use.html.erb", "aids.html.erb", 
"expectations.html.erb", "faq.html.erb", "privacy_policy.html.erb", "contact_us.html.erb"]

ตอนนี้ สิ่งที่ฉันต้องการทำคือสิ่งที่คุณสามารถทำได้ในการพัฒนาเพื่อเปลี่ยนข้อมูลรับรอง nano rails credentials:edit แต่การทำ nano rails home.html.erb:edit หรือ nano rails home:edit ไม่ได้ผล นี่คือผลลัพธ์พร้อมวิธีต่างๆ ทั้งหมดที่ฉันได้ลอง:

irb(main):003:0> nano rails home.html.erb:edit
Traceback (most recent call last):
    1: from (irb):3
NameError (undefined local variable or method `home' for main:Object)

irb(main):004:0> nano rails home:edit
Traceback (most recent call last):
    2: from (irb):3
    1: from (irb):4:in `rescue in irb_binding'
NameError (undefined local variable or method `edit' for main:Object)
Did you mean?  exit

irb(main):005:0> nano home:edit
Traceback (most recent call last):
    2: from (irb):4
    1: from (irb):5:in `rescue in irb_binding'
NameError (undefined local variable or method `edit' for main:Object)
Did you mean?  exit 

irb(main):006:0> home:edit
Traceback (most recent call last):
    2: from (irb):5
    1: from (irb):6:in `rescue in irb_binding'
NoMethodError (undefined method `home' for main:Object)

irb(main):007:0> home.html.erb:edit
Traceback (most recent call last):
    2: from (irb):6
    1: from (irb):7:in `rescue in irb_binding'
NameError (undefined local variable or method `home' for main:Object)

irb(main):008:0> edit home.html.erb
Traceback (most recent call last):
    2: from (irb):7
    1: from (irb):8:in `rescue in irb_binding'
NameError (undefined local variable or method `home' for main:Object)

irb(main):009:0> edit home
Traceback (most recent call last):
    2: from (irb):8
    1: from (irb):9:in `rescue in irb_binding'
NameError (undefined local variable or method `home' for main:Object)

irb(main):010:0> edit "home.html.erb"
Traceback (most recent call last):
    2: from (irb):9
    1: from (irb):10:in `rescue in irb_binding'
NoMethodError (undefined method `edit' for main:Object)
Did you mean?  exit

เป็นไปได้ไหม? หรือเป็นเพราะการควบคุมเวอร์ชันที่ไม่ได้รับอนุญาต และคุณต้องทำในเครื่อง คอมมิตไปที่ git แล้วกด git master เพื่อทำการเปลี่ยนแปลง? สงสัยเพราะคงจะดีถ้าแก้ไขอย่างรวดเร็วโดยไม่ต้องทำตามขั้นตอนอื่นๆ ทั้งหมด และโดยไม่ต้องทำให้เพจเป็นไดนามิกและจัดเก็บข้อมูลลงในตารางเพื่อแก้ไขในเบราว์เซอร์

ขอบคุณสำหรับข้อมูลเชิงลึกของคุณ


person Christopher Warrington    schedule 26.06.2020    source แหล่งที่มา


คำตอบ (1)


ก่อนอื่น (นอกเหนือจากการอ้างอิงในอนาคต) ดูเหมือนว่าคุณจะปฏิบัติต่อคอนโซลเหมือนกับว่ามันเป็น bash shell แต่ heroku console เพิ่งหมุนคอนโซล Rails ดังนั้น สิ่งต่างๆ เช่น nano rails... ใช้งานไม่ได้เนื่องจากไม่ใช่ Ruby ที่ถูกต้อง การวิ่ง heroku run bash จะทำให้ไดโนหมุนครั้งเดียวและมอบ bash shell ให้กับคุณ

เพื่อตอบคำถามหลักของคุณ การพุชสาขา git เป็นวิธีหนึ่งที่จะผลักดันการเปลี่ยนแปลงของคุณออกไป มีสองสิ่งที่ต้องเข้าใจเกี่ยวกับ Heroku ที่ช่วยอธิบายเหตุผล:

  1. เมื่อคุณเรียกใช้ heroku run bash Heroku จะสร้าง dyno แยกต่างหากสำหรับเซสชันนั้นพร้อมกับสำเนาของโครงสร้างไฟล์แอปพลิเคชันของคุณ เป็นวิธีที่ดีสำหรับการแก้ไขปัญหา แต่จริงๆ แล้วไม่ได้เชื่อมต่อคุณกับ dyno ที่ใช้งานแอปพลิเคชันของคุณแต่อย่างใด ดังนั้นหากคุณแก้ไขไฟล์ที่นั่น ไฟล์นั้นจะไม่ส่งผลต่อโค้ดแอปที่รันอยู่
  2. เมื่อคุณส่งรูปภาพไปที่ Heroku มันจะสร้างรูปภาพที่บรรจุไว้ล่วงหน้าของแอปพลิเคชันของคุณที่เรียกว่าตัวบุ้ง เมื่อใดก็ตามที่คุณรีสตาร์ทแอป แอปจะโหลดซ้ำจากทากเหล่านั้น ดังนั้นแม้ว่าคุณจะใช้แฮ็กเพื่อเชื่อมต่อกับ dyno ที่กำลังรันอยู่และเปลี่ยนไฟล์ แอปก็จะคงอยู่จนกระทั่งในครั้งถัดไปที่แอปรีสตาร์ทเท่านั้น
person rmlockerd    schedule 26.06.2020
comment
ขอบคุณสำหรับคำตอบที่กระชับมาก ... ถ้าอย่างนั้น ฉันจะต้องทำการเปลี่ยนแปลงเล็กๆ น้อยๆ เหล่านั้นแยกกันและผลักดันมันขึ้นมา ยกนิ้วให้ ~ ขอให้สนุกกับการเขียนโค้ด! - person Christopher Warrington; 27.06.2020