If you are managing an application that has a staging version, you will need to point default_url_options[:host] to the correct host domain. If not, features that depend on host domains(i.e. uploading to cloudinary or sending out an email from your application)will not work.
I recently had a job interview for a Junior Rails role with a company. I was tasked to complete one of three exercises, one of which was a to-do list. I decided to utilize hotwire in order to expand my understanding of it.
I’m working on a Rails 6 project that is still dependent on sprockets. Which means I am often clobbering and precompiling when cleaning up on CSS styling. Setting up aliases help me save time.
alias rap='bin/rails assets:precompile && bin/rails s'alias rac='bin/rails assets:clobber && bin/rails assets:precompile && bin/rails s'
Update–
You might not have to clobber and pre-compile. It may be an issue with a webpacker dependency. To fix, try deleting public/packs and public/assets.
I’ve been tinkering with request.js and it’s quite magical. From the client, we can make make typical REST requests get, post, put, patch, destroy. We can even deliver a turbo-stream response. By adding responseKind: "turbo-stream" to the options config, you can receive some_action.turbo_stream.erb. When hooked with a stimulus controller, the implementation is easier than you would imagine.
<!-- pages/index.html.erb --><divclass="flex flex-col"data-controller="activity"><div>
What would you like to do?
<%=select_tag"activity",options_for_select(@options),{include_blank:true,data:{activity_target:"input",url:what_to_do_path,action:"change->activity#select" } } %>
</div><div><divdata-activity-target="loading"class="hidden">Loading...</div><%=turbo_frame_tag"option"%></div></div>
In the stimulus controller I import get from the request.js library. When a change event is triggered on the select tag, select() makes a get request. Notice how I use new URLSearchParams to append the param to the url. You can also return a Promise object with your request.
A really simple way to apply dark mode on your webpage is including a CSS media query. The browser checks the users system display settings and sets accordingly. ☺︎