-
Hi, I saw this gem over at the Inertia Discord, but I'm having some issues getting it setup. I've not been about to get the modules to resolve with the default paths, I've had to do below not to get webpack-dev compiling errors and I get
I'm also getting below error if I fix the paths ? Any ideas ? Repo where I'm trying to roll this out I'm actually doing this to try and get the Avatar object/url /* error */
/* all.js */ // JsFromRoutes CacheKey 59a045b933dbb474391f6c2be55a6ca6
//
// DO NOT MODIFY: This file was automatically generated by JsFromRoutes.
// export { default as usersSessions } from "~/api/Users/SessionsApi";
// export { default as usersRegistrations } from "~/api/Users/RegistrationsApi";
// export { default as recipes } from "~/api/RecipesApi";
// export { default as inertiaExample } from "~/api/InertiaExampleApi";
// export { default as pages } from "~/api/PagesApi";
// export { default as users } from "~/api/UsersApi";
export { default as usersSessions } from "./Users/SessionsApi";
export { default as usersRegistrations } from "./Users/RegistrationsApi";
export { default as recipes } from "./RecipesApi";
export { default as inertiaExample } from "./InertiaExampleApi";
export { default as pages } from "./PagesApi";
export { default as users } from "./UsersApi"; import React from "react";
import { InertiaLink } from "@inertiajs/inertia-react";
import { Inertia } from "@inertiajs/inertia";
import { recipes } from "../api/all";
import SearchFilter from "../Components/SearchFilters";
const Recipe = ({ user, recipe }) => {
const recipeTest = recipes.get({ id: 2 });
const deleteHandler = () => {
console.log(`/recipes/${recipe.id}`);
// Inertia.delete(`/recipes/${recipe.id}`);
// Inertia.visit(`/recipes/${recipe.id}`, { method: "delete" });
Inertia.delete(`/recipes/${recipe.id}`, {
onBefore: () => confirm("Are you sure you want to delete this user?"),
});
};
return (
<> /* routes */ Rails.application.routes.draw do
#
# export the whole app to js_routes
defaults export: true do
devise_for :users, skip: %i[sessions passwords registrations]
as :user do
get 'login', to: 'users/sessions#new', as: :new_user_session
post 'login', to: 'users/sessions#create', as: :user_session
get 'new', to: 'users/registrations#new', as: :new_user_registration
post 'new', to: 'users/registrations#create', as: :user_registration
get 'edit', to: 'users/registrations#edit', as: :edit_user_registration
patch 'edit', to: 'users/registrations#update', as: :update_user_registration
match 'logout', to: 'users/sessions#destroy', as: :destroy_user_session, via: Devise.mappings[:user].sign_out_via
end
root to: 'recipes#index'
get 'inertia-example', to: 'inertia_example#index'
get 'pages/home'
# root to: 'pages#home'
resources :recipes, only: %i[index show new create edit update destroy]
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :users, only: [:show]
end
end |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi Chris! @matoni109 In order for webpack to resolve Here's an example of how to configure an alias in webpacker. module.exports = {
resolve: {
alias: {
'~': path.resolve(__dirname, '..', '..', 'app/javascript'), Make sure to adjust the resolve call based on the location of the file, you want |
Beta Was this translation helpful? Give feedback.
Hi Chris! @matoni109
In order for webpack to resolve
~/
paths you need to configure an alias (comes by default if you are using Vite Ruby).Here's an example of how to configure an alias in webpacker.
Make sure to adjust the resolve call based on the location of the file, you want
~
to resolve toapp/javascript
, so that~/api
is resolved toapp/javascript/api
where the files are located.