Fueling Curiosity, One Insight at a Time
At Codemancers, we believe every day is an opportunity to grow. This section is where our team shares bite-sized discoveries, technical breakthroughs and fascinating nuggets of wisdom we've stumbled upon in our work.
Mar 28, 2025
Turbo provides a built-in way to show a loading state on form submission using the
Instead of manually handling the button's disabled state or adding a spinner, you can simply use:
• When the form is submitted, Turbo automatically
replaces the button text with the value provided in
• Button is also disabled until the request completes.
• Once the request completes, the button reverts to its original text.
No extra JavaScript needed! 🎉
This is a great way to enhance UX with minimal effort. #Rails #Turbo #TIL
turbo_submits_with
attribute! 🚀Instead of manually handling the button's disabled state or adding a spinner, you can simply use:
<%= form.submit t("post.create"),
data: { turbo_submits_with: t('loading.saving') } %>
• When the form is submitted, Turbo automatically
replaces the button text with the value provided in
turbo_submits_with
(e.g., "Saving..."
).• Button is also disabled until the request completes.
• Once the request completes, the button reverts to its original text.
No extra JavaScript needed! 🎉
This is a great way to enhance UX with minimal effort. #Rails #Turbo #TIL
Nived Hari
System Analyst
Mar 21, 2025
while using
In order to allow the floating point value we can add
#CU6U0R822 #form-tag-helper
form.number_field
in rails if we enter a floating point value eg: 23.45
then browser default validation kicks in syaing: Please enter a valid value. The two nearest valid values are 23 & 24
.In order to allow the floating point value we can add
form.number_field, step: "0.01"
. Then we can add upto two decimal point vlaue.#CU6U0R822 #form-tag-helper
satya
Mar 21, 2025
to terminate google chrome sessions ->
#terminate-session
pkill -9 "Google Chrome"
.#terminate-session
satya
Mar 20, 2025
Ruby Heredoc Syntax & Rails .squish method:
• Bad - Regular heredoc (<<) keeps all whitespace
• Good - Squiggly heredoc (<<) removes leading whitespace
```
query = <<SQL
SELECT *
FROM users
SQL
# Result: "SELECT \nFROM users\n"
```
• *Best - Rails
#ruby-heredoc #rails-squish
• Bad - Regular heredoc (<<) keeps all whitespace
query = <<SQL
SELECT *
FROM users
SQL
# Result: " SELECT *\n FROM users\n"
• Good - Squiggly heredoc (<<
```
query = <<
SELECT *
FROM users
SQL
# Result: "SELECT \nFROM users\n"
```
• *Best - Rails
.squish
removes all extra whitespace/newlines
query = <<~SQL.squish
SELECT *
FROM users
WHERE active = true
SQL
# Result: "SELECT * FROM users WHERE active = true"
#ruby-heredoc #rails-squish
satya
Mar 20, 2025
TimescaleDB
When working with time series data like stock prices, website traffic, or error logs, the volume of data grows rapidly over time. In traditional relational databases like PostgreSQL and SQL, this can lead to slower query performance as the dataset becomes larger.
One alternative is to use NoSQL databases, but they come with their own challenges, such as lack of strong ACID compliance, complex querying, and difficulties in handling structured relational data.
TimescaleDB, which is built on top of PostgreSQL, offers a powerful solution by introducing hypertables - a special type of table optimised for time series data. Hypertables enable faster read and write operations, automatic partitioning, and efficient data compression. Additionally, TimescaleDB provides advanced analytical functions, making it easier to perform complex queries for reporting, trend analysis, and forecasting. This makes it a great choice for applications that require efficient storage and analysis of large-scale time series data.
#databases #time_series_data #timescale_db #postgres
When working with time series data like stock prices, website traffic, or error logs, the volume of data grows rapidly over time. In traditional relational databases like PostgreSQL and SQL, this can lead to slower query performance as the dataset becomes larger.
One alternative is to use NoSQL databases, but they come with their own challenges, such as lack of strong ACID compliance, complex querying, and difficulties in handling structured relational data.
TimescaleDB, which is built on top of PostgreSQL, offers a powerful solution by introducing hypertables - a special type of table optimised for time series data. Hypertables enable faster read and write operations, automatic partitioning, and efficient data compression. Additionally, TimescaleDB provides advanced analytical functions, making it easier to perform complex queries for reporting, trend analysis, and forecasting. This makes it a great choice for applications that require efficient storage and analysis of large-scale time series data.
#databases #time_series_data #timescale_db #postgres
Puneeth kumar
System Analyst
Mar 19, 2025
We can't use turbo frame for table rows, because html doesn't allow external tag like turbo frame inside the table.
The workaround this is to just have unique id for element you want to modify and use turbosteam to modify only that element.
#rubyonrails #turbo #turboframes #spa
The workaround this is to just have unique id for element you want to modify and use turbosteam to modify only that element.
#rubyonrails #turbo #turboframes #spa
Aditya Vishwakarma
System Analyst
Mar 19, 2025
in ruby
#ruby, #nil-conversion
https://nil.to|nil.to_i
=> 0
& https://nil.to|nil.to_f
=> 0.0
#ruby, #nil-conversion
satya
Mar 18, 2025
Steps to merge one repo into another
Step 1: Clone Repo1 locally
Step 2: Fetch all the branches and commits from Repo2
Step 3: Create a branch
Step 4: Merge keeping full history
Step 5: Resolve Merge Conflicts
#git
Step 1: Clone Repo1 locally
git clone repo1
cd repo1
Step 2: Fetch all the branches and commits from Repo2
git remote add repo2
git fetch repo2
Step 3: Create a branch
git checkout -b merge-repo2
Step 4: Merge keeping full history
git merge --allow-unrelated-histories repo2/main (Since the repositories have separate histories, this option allows Git to combine them, potentially requiring manual conflict resolution)
Step 5: Resolve Merge Conflicts
git add .
git commit -m "Resolved merge conflicts"
#git
sujay
Mar 18, 2025
pagy_array
This method is the same as the generic pagy
method, but specialized for an Array.
require 'pagy/extras/array'
@pagy, @items = pagy_array(an_array)
#CU6U0R822 #ruby
Mohammad hussain
System Analyst
Mar 18, 2025
```
pagy_array
Mohammad hussain
System Analyst
Showing 1 to 5 of 76 results
Ready to Build Something Amazing?
Codemancers can bring your vision to life and help you achieve your goals
- Address
2nd Floor, Zee Plaza,
No. 1678, 27th Main Rd,
Sector 2, HSR Layout,
Bengaluru, Karnataka 560102 - Contact
hello@codemancers.com
+91-9731601276