rafal.siepak PRO
Joined 7/31/2022
rafal.siepak PRO said over 2 years ago on Slim Select with Stimulus :
Hello,

I have encountered two issues:

1) I get the following error with css: 

[ERROR] Could not resolve "slim-select/dist/slimselect.css"
13:16:32 js.1   | 
13:16:32 js.1   |     app/javascript/controllers/select_controller.js:3:7:
13:16:32 js.1   |       3 │ import "slim-select/dist/slimselect.css"
13:16:32 js.1   |         ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13:16:32 js.1   | 
13:16:32 js.1   |   The path "./dist/slimselect.css" is not exported by package


2) In case of multiple select I get the following error:


undefined local variable or method `group' for #<ActionView::Base:0x00000000028e60>

                group.decks.map { |c| [c.name, c.id] }, {},
                ^^^^^
Did you mean?  group_url

Could you help here? Thank you. 

rafal.siepak PRO said over 2 years ago on Slim Select with Stimulus :
For the first issue, just to let you know. I am using rails 7 with Taiwlind and esbuild. What should I do to make it working?

rafal.siepak PRO said over 2 years ago on Slim Select with Stimulus :
I have made it work by putting directly @import "slim-select/dist/slimselect.css" into application.tailwind.css.

Another question I have is I want to render html under index page, but right now after applying the code I only render json. How to make both work HTML and json?

class CategoriesController < ApplicationController
  def index
    @categories = Category.where("name like ?", "%#{params[:query]}%")
    render json: @categories.map { |c| { value: c.id, text: c.name } }
  end
end

rafal.siepak PRO said over 2 years ago on Slim Select with Stimulus :
I am trying to do apply such.code, but it does not work:

def index
    @decks = Deck.all
    respond_to do |format|
      format.html
      format.json {
        @decks = Deck.where("name ILIKE ?", "%#{params[:query]}%")
        render json: @decks.map { |c| { value: c.id, text: c.name } }}
    end
  end