Quick question! urgent... error in saving the changes in a webpage

well, I have an ember/rails project, website this website shows on the main page event cards, and has a button to create a new event on the top. On these cards/ event -summary it is displayed the title of the event and the date are. Once click on this card, it will go to another page to display its format, its description. On this page, there is a button edit. Once I click the edit button it will go to edit.hbs. My problem is when I edit the page, I will click on save changes yet this button is not properly working INSTEAD of saving the changes, it undos them (as if I did not change the file)

before providing you with the necessary files, I tried to investigate this issue and went to the edit page and inspect it and got this error ught TypeError: Cannot read properties of undefined (reading 'browserobject") t webcontent. js: 1: 266 it webcontent. js: 2:463 at webcontent. js: 2:467 caught TypeError: event.save is not a function at EventsEditController.saveEvent (edit.js: 16:1) 8 lssues: 日8 webcontent. js: 1 edit.js:16

However I do not have a file called webcontent.js !!!

what can I do? please help as I cannot move forward I have been 2 days on this bug

(here are the additional files edit .js import Controller from ‘@ember/controller’; import { action } from ‘@ember/object’;

export default class EventsEditController extends Controller { @action saveEvent() { let event = this.model; event.save().then(() => { this.transitionToRoute(‘events.show’, event.id); }); } }

edit.hbs

Edit Event

Name
  <div class="form__group">
    <label class="form__label">Description</label>
    <Textarea @value={{this.model.description}} class="form__textarea" />
  </div>

  <div class="form__group">
    <label class="form__label">Location</label>
    <Input @value={{this.model.location}} class="form__input" />
  </div>

  <div class="form__group">
    <label class="form__label">Event date</label>
    <Input @value={{this.model.eventDate}} class="form__input" @type="date" />
  </div>

  <div class="form__group">
    <label class="form__label">Start time</label>
    <Input @value={{this.model.startTime}} class="form__input" @type="time" />
  </div>

  <div class="form__group">
    <label class="form__label">End time</label>
    <Input @value={{this.model.endTime}} class="form__input" @type="time" />
  </div>

  <div class="form__group">
    <label class="form__label">Published</label>
    {{input type="checkbox" checked=this.model.published}}
  </div>

  <button type="submit" class="form__btn">Save Changes</button>
</form>

routes.rb Rails.application.routes.draw do

The priority is based upon order of creation: first created → highest priority.

See how all your routes lay out with “rake routes”.

You can have the root of your site routed with “root”

root ‘welcome#index’

Example of regular route:

get ‘products/:id’ => ‘catalog#view’

Example of named route that can be invoked with purchase_url(id: product.id)

get ‘products/:id/purchase’ => ‘catalog#purchase’, as: :purchase

Example resource route (maps HTTP verbs to controller actions automatically):

get ‘events’ => ‘events#index’ get ‘events/:slug’ => ‘events#show’ post ‘events’ => ‘events#create’ put ‘events/:slug’ => ‘events#update’ # This is your new PUT route

Example resource route with options:

resources :products do

member do

get ‘short’

post ‘toggle’

end

collection do

get ‘sold’

end

end

Example resource route with sub-resources:

resources :products do

resources :comments, :sales

resource :seller

end

Example resource route with more complex sub-resources:

resources :products do

resources :comments

resources :sales do

get ‘recent’, on: :collection

end

end

Example resource route with concerns:

concern :toggleable do

post ‘toggle’

end

resources :posts, concerns: :toggleable

resources :photos, concerns: :toggleable

Example resource route within a namespace:

namespace :admin do

# Directs /admin/products/* to Admin::ProductsController

# (app/controllers/admin/products_controller.rb)

resources :products

end

end

and events_controller.rb class EventsController < ApplicationController def index @events = Event.where(published: true) render json: @events end

def show render json: find_event_by_slug_or_id end

def create event = Event.new(filtered_params)

if event.save
  render json: event
else
  render json: { errors: event.errors }, status: 422
end

end

def update event = find_event_by_slug_or_id

if event.update(filtered_params)
  render json: event
else
  render json: { errors: event.errors }, status: :unprocessable_entity
end

end

private

def filtered_params params.require(:event).permit( :name, :description, :location, :event_date, :start_time, :end_time, :published ) end

def find_event_by_slug_or_id Event.find_by(slug: params[:slug]) || Event.find_by(id: params[:slug]) end end )

routes.rb Rails.application.routes.draw do

The priority is based upon order of creation: first created → highest priority.

See how all your routes lay out with “rake routes”.

You can have the root of your site routed with “root”

root ‘welcome#index’

Example of regular route:

get ‘products/:id’ => ‘catalog#view’

Example of named route that can be invoked with purchase_url(id: product.id)

get ‘products/:id/purchase’ => ‘catalog#purchase’, as: :purchase

Example resource route (maps HTTP verbs to controller actions automatically):

get ‘events’ => ‘events#index’ get ‘events/:slug’ => ‘events#show’ post ‘events’ => ‘events#create’ put ‘events/:slug’ => ‘events#update’ # This is your new PUT route

Example resource route with options:

resources :products do

member do

get ‘short’

post ‘toggle’

end

collection do

get ‘sold’

end

end

Example resource route with sub-resources:

resources :products do

resources :comments, :sales

resource :seller

end

Example resource route with more complex sub-resources:

resources :products do

resources :comments

resources :sales do

get ‘recent’, on: :collection

end

end

Example resource route with concerns:

concern :toggleable do

post ‘toggle’

end

resources :posts, concerns: :toggleable

resources :photos, concerns: :toggleable

Example resource route within a namespace:

namespace :admin do

# Directs /admin/products/* to Admin::ProductsController

# (app/controllers/admin/products_controller.rb)

resources :products

end

end

and events_controller.rb class EventsController < ApplicationController def index @events = Event.where(published: true) render json: @events end

def show render json: find_event_by_slug_or_id end

def create event = Event.new(filtered_params)

if event.save
  render json: event
else
  render json: { errors: event.errors }, status: 422
end

end

def update event = find_event_by_slug_or_id

if event.update(filtered_params)
  render json: event
else
  render json: { errors: event.errors }, status: :unprocessable_entity
end

end

private

def filtered_params params.require(:event).permit( :name, :description, :location, :event_date, :start_time, :end_time, :published ) end

def find_event_by_slug_or_id Event.find_by(slug: params[:slug]) || Event.find_by(id: params[:slug]) end end )