DEV Community

Discussion on: Live query render with Rails 6 and Stimulus JS

Collapse
 
mirmayne profile image
Daveyon Mayne 😻

Hi @maxencep40 . What are you referring to exactly? An example?

Collapse
 
maxencep40 profile image
MaxencePautre

Thank you for your answer. I created a SO post about the issue I'm facing here. Did you keep your repo of this post ?

Thread Thread
 
mirmayne profile image
Daveyon Mayne 😻 • Edited

Ok. I use post because I'm sending data to the backend. You use get when you "want" something only (nothing to send in the body request). The key part is the method name: filter. Ensure the name filter matches the name of your view path/filename. This is a rails convention.

Namespacing.

In this post, I'm talking about customers so you'll have a path like this:

  • /controllers/customers/*

In that folder, you'll have all the controllers (classes) related to "customer":

  • /controllers/customers/customers_controller.rb (CRUD actions)
  • /controllers/customers/filter_controller.rb (All other actions that are not CRUD)

I talk about keeping your controller folders organised instead of having all the files in controllers/. Models would be the same:

  • /models/customers/<model-name>.rb
Thread Thread
 
maxencep40 profile image
MaxencePautre

Alright thanks for the details. I didn't use filter but search and I made sure the views path matched but I'm still getting the error in the SO post.
Would be useful if you someday get your hand on your repo so I can compare more precisely ;)

Thread Thread
 
mirmayne profile image
Daveyon Mayne 😻 • Edited

Could be many things. Your form is also missing the data-remote="true" That is needed and you're submitting with a button. Different from what I have. When I can I'll have a look.

Thread Thread
 
maxencep40 profile image
MaxencePautre • Edited

No it's just that since rails 6.1 you need to put local: false to submit via Ajax on the form_with