Learning App for Moms Learn to Code, find it at https://learn.momslearntocode.com.
git clone git@github.com:hhar/mltc_learning_app.git
cd mltc_learning_appruby -vThe ouput should start with something like ruby 3.0.2
If not, install the right ruby version using rbenv (it could take a while):
rbenv install 3.0.2bundle && yarnrails db:create db:migrate db:seedrails sfly deployrails consolefly ssh console --pty -C "/app/bin/rails console"The
--ptyflag is required to allocate a pseudo-TTY, otherwise IRB raises anErrno::ENOTTYerror.
You must be logged in as an admin. Navigate to:
/lessons/<lesson_id>/materials/<material_id>/edit
To list all materials for a lesson:
/lessons/<lesson_id>/materials
Find a material:
# By lesson name
lesson = Lesson.find_by(name: "HTML and CSS Introduction")
lesson.materials
# Find a specific task material
task = lesson.materials.where(type: "TaskMaterial").first
# or by id
task = TaskMaterial.find(87)View content:
task.body.to_plain_text
task.body.body.to_htmlUpdate content:
task.body = "<ol><li>New task text</li></ol>"
task.save!Find and replace within existing content:
new_html = task.body.body.to_html.gsub("old string", "new string")
task.body = new_html
task.save!Always assign to
task.body =directly (nottask.body.body =), otherwise Rails won't detect the change and won't save it.
lesson = Lesson.find_by(name: "My Lesson")
TaskMaterial.create!(lesson: lesson, body: "<ol><li>Task 1</li></ol>")user = User.find_by(email: "user@example.com")
user.courses << Course.find_by(title: "Course Title")
# or explicitly:
Subscription.create!(user: user, course: Course.find(1))