Rails update attributes not updating
attribute for the pets that you would like to be removed. Following is an example of how it should be implemented in your view.
This is mostly useful in relation to single-table inheritance structures where you want a subclass to appear as the superclass.
Deletes the record in the database and freezes this instance to reflect that no changes should be made (since they can't be persisted). The row is simply removed with an SQL Deletes the record in the database and freezes this instance to reflect that no changes should be made (since they can't be persisted).
If the model is new, a record gets created in the database, otherwise the existing record gets updated. However, if you supply the action is cancelled and save!
Newly updated for Rails 5, the Ruby on Rails Tutorial book and screencast series teach you how to develop and deploy real, industrial-strength web applications with Ruby on Rails, the open-source web framework that powers top websites such as Twitter, Hulu, Git Hub, and the Yellow Pages.
I'm stuck and i don't know why it is not working right. When i update the lesson rails update properly the lesson attributes but is creating another sublessons records instead of just updating it.
Here is my code View Form: "lesson_id" validates :sublesson_name, presence: true validates :sublesson_content ,presence: true end lesson controller def update @lesson = Lesson.find(params[:id]) @[email protected] @lesson.update(lesson_params) flash[:notice] = "Lesson updated" redirect_to lessons_show_url else flash[:notice] = "Error" redirect_to lessons_show_url end end def edit @lesson = Lesson.find(params[:id]) @[email protected] def lesson_params params.require(:lesson).permit(:lesson_name, :lesson_icon, sublessons_attributes:[:sublesson_id, :sublesson_name, :sublesson_content, :sublesson_video_link]) end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
Search for rails update attributes not updating:
If you want to change the sti column as well, use becomes! Wrapper around becomes that also changes the instance's sti column value.