Bootstrap with Rails 7

Issue 1: javascript_importmap_tags error

If you get:

undefined local variable or method `javascript_importmap_tags' for an instance of #Code language: JavaScript (javascript)

Go to app/views/layouts/application.html.erb and remove the line with:

      <%= javascript_importmap_tags %>Code language: HTML, XML (xml)

Issue 2: application.css error

If you get the

The asset "application.css" is not present in the asset pipeline.Code language: JavaScript (javascript)

Do:

yarn add sass
yarn build:cssCode language: CSS (css)

Issue 3: Delete not working

If delete does not work, you need to add this to app/views/layouts/application.html.erb:

<%= javascript_include_tag "turbo", type: "module" %>Code language: JavaScript (javascript)

Issue 4: After delete you get a record not found error

The controller current has:

def destroy
    @friend = Friend.find(params[:id])
    @friend.destroy

    redirect_to "/Friends", status: :see_other                                                   
  endCode language: CSS (css)

We need to redirect back to the main page. Changer the redirtect_to to:

def destroy
    @friend = Friend.find(params[:id])
    @friend.destroy

    redirect_to root_path, status: :see_other
  endCode language: CSS (css)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top