119
loading...
This website collects cookies to deliver better user experience
rails7
branch. Fortunally I didn't have to make any changes to my deployed master, but merging branches was always in the back of my mind.bin/rails app:update
and it did its thing. I hate to admint this, but I have No tests. I've tried many times to get into the test mode, but failed! So I continued to test how I've tested for the last 40 years! Change something then push the car back up the hill and see if the brakes fail again!!gem 'sass-rails'
was still in the Gemfile config.active_record.migration_error = false
to avoid the error and later on changed require "rails/all"
to the documentation way to not require ActiveStorage.gem "rails", "~> 7.0.0"
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"
# Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]
gem "tailwindcss-rails"
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
gem "redis", "~> 4.0"
import { Controller } from "@hotwired/stimulus"
config/importmap.rb
my unique CDNspin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin_all_from "app/javascript/controllers", under: "controllers"
pin "stimulus-flatpickr", to: "https://ga.jspm.io/npm:[email protected]/dist/index.m.js"
pin "flatpickr", to: "https://ga.jspm.io/npm:[email protected]/dist/flatpickr.js"
pin "stimulus-autocomplete", to: "https://ga.jspm.io/npm:[email protected]/src/autocomplete.js"
pin "@hotwired/stimulus", to: "https://ga.jspm.io/npm:@hotwired/[email protected]/dist/stimulus.js"
link rel="stylesheet" href="https://ga.jspm.io/npm:[email protected]/dist/flatpickr.min.css"
config/tailwind.js
file.const defaultTheme = require('tailwindcss/defaultTheme')
module.exports = {
content: [
'./app/helpers/**/*.rb',
'./app/javascript/**/*.js',
'./app/views/**/*.html.*',
'./app/components/**/*.html.*'
],
theme: {
extend: {
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
},
colors: {
'orange': '#ffa500',
'malt': '#991A1E',
'gold': '#A79055',
'dark-blue': '#0F3E61',
'success': '#63ed7a',
'secondary': "#9db3b8",
'w3green': "#4CAF50",
'w3red': "#f44336",
'blue-link': "#00c",
lime: {
lightest: '#f1fff1',
lighter: '#e2ffe2',
light: '#c9ffc9',
DEFAULT: '#b8ffb8',
dark: '#96ff96',
darker: '#7cff7c',
darkest: '#49ff49',
},
// gray: colors.trueGray,
green: {
lighter:'hsla(122, 59%, 64%, 1)',
light: 'hsla(122, 49%, 54%, 1)',
DEFAULT: 'hsla(122, 39%, 49%, 1)',
dark: 'hsla(122, 39%, 39%, 1)',
darker: 'hsla(122, 39%, 29%, 1)',
},
},
},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/aspect-ratio'),
require('@tailwindcss/typography'),
]
}
content:
array@apply
and converted them to rails helpers. Something like:module ComponentsHelper
def greenBox
"box-border box-content m-3 p-4 bg-green-300 border-green-100 border-2 text-black"
end
def blueBox
"box-border box-content m-3 p-4 bg-blue-400 border-blue-200 border-2 text-black"
end
def btn
"py-1 px-2 text-black hover:text-white rounded font-lg font-bold "
end
def btnInfo
btn + "bg-blue-400 text-blue-link hover:text-blue-100"
end
def btnWarn
btn + "bg-orange hover:text-yellow-200"
end
def btnGreen
btn + "bg-green-500 hover:text-green-100"
end
def btnDanger
btn + "bg-red-500 hover:text-red-200"
end
def btnSuccess
btn + "bg-success hover:bg-green-700"
end
def btnSecondary
btn + "bg-secondary"
end
def flashAlert(type)
case type
when 'danger'
return "bg-red-200 text-red-600"
when 'info'
return "bg-blue-200 text-blue-600"
when 'success'
return "bg-green-200 text-green-600"
when 'warning'
return "bg-yellow-400 text-yellow-800"
else
return "bg-gray-200 text-gray-600"
end
end
def destroyConfirmTag(model,confirm_msg:"",klass:"",prompt:"")
klass= "#{btnDanger} inline-block" if klass.blank?
confirm_msg = "Are You Sure?" if confirm_msg.blank?
prompt = "Delete #{model.class.name}" if prompt.blank?
node = content_tag(:div, class: klass,
data:{
controller:"destroyConfirm",
action:"click->destroyConfirm#confirm",
destroyConfirm_cmsg_value:confirm_msg
}){
concat(tag.span(prompt))
concat(button_to( '',model, method: :delete,class:"hidden",data:{destroyConfirm_target:"submit"}))
}
node
end
end
destroyConfirmTag
tackled the problem with Rails removing the method::get
from delete scaffold. The default change is to change link_to
to button_to
. But it didn't have a confirm tag. So I just call this on delete links and add back the confirm message. I have a couple delete links that I need to sure they didn't click the wrong link. There is a simple stimulus controller:import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = [ "submit"]
static values = { cmsg: String}
connect() {
// console.log("destroy confirm")
if (this.hasCmsgValue) {
this.confirm_msg = this.cmsgValue
}else{
this.confirm_msg = "Are you sure?"
}
}
confirm(){
// console.log(this.submitTarget.closest('form'))
let ans = confirm(`${this.confirm_msg}`)
if (ans == true) {
this.submitTarget.closest('form').submit()
}
}
}
class TwColors
attr_accessor :colors, :css
Colors = {:colors=>
{:orange=>"#ffa500",
:malt=>"#991A1E",
:gold=>"#A79055",
:"dark-blue"=>"#0F3E61",
:lime=>
{:lightest=>"#f1fff1",
:lighter=>"#e2ffe2",
:light=>"#c9ffc9",
:DEFAULT=>"#b8ffb8",
:dark=>"#96ff96",
:darker=>"#7cff7c",
:darkest=>"#49ff49"},
:green=>
{:lighter=>"hsla(122, 59%, 64%, 1)",
:light=>"hsla(122, 49%, 54%, 1)",
:DEFAULT=>"hsla(122, 39%, 49%, 1)",
:dark=>"hsla(122, 39%, 39%, 1)",
:darker=>"hsla(122, 39%, 29%, 1)"}}}
def initialize()
@colors = Colors
@css = "not parsed yet \n"
@colors[:colors].each do |k,v|
unless v.is_a?(Hash)
add_color_classes(k,v)
else
add_nested_color_classes(k,v)
end
end
puts @css
end
def add_color_classes(k,v)
@css << ".text-#{k} {\n\tcolor: #{v};\n}"
@css << ".bg-#{k} {\n\t background-color: #{v};\n}\n"
end
def add_nested_color_classes(k,v)
v.each do |kk,vv|
if kk.to_s == "DEFAULT"
add_color_classes("#{k}",vv)
else
add_color_classes("#{k}-#{kk}",vv)
end
end
end
end
What if I merged and Capistrono would not deploy
. I spent way too much time trying to figure out how to deploy a branch to my staging server. I found posts on how to do it (old) and nothing worked.bin/rails assets:clobber
when I moved back to development.cap staging deploy
also worked without any changes to the Capistrono config file.