Forum https://discourse.hanamirb.org – Code of Conduct http://hanamirb.org/community/#code-of-conduct
adam12 on pg-env-variables
Revert "Log ENV" This reverts … Never prompt for password in Gi… (compare)
adam12 on pg-env-variables
Log ENV (compare)
adam12 on pg-env-variables
Pass environment variables to e… (compare)
adam12 on pg-env-variables
fixup! Pass env to system in po… (compare)
adam12 on pg-env-variables
Pass env to system in postgresq… Remove manual PGPASSWORD settin… Call postgresql command with en… (compare)
Ah yes I saw that - I was interested as to that - a note there
Custom schema takes precedence over automatic schema. If we use custom schema, we need to manually add all the new columns from the corresponding SQL database table.
Which is unclear to me. If I use custom schema attributes, does it completely override the other columns? Or can I use both - sometimes its just nice to have some overlying business logic validations to ensure bad data cannot enter the persistence layer at that boundary
Sequel::InvalidValue at
ArgumentError: no time information in ""
def call(params)
@page = PageRepository.by_title(params[:id])
if @page.nil?
@page = Page.new(title: params[:id])
self.body = Web::Views::Pages::NotFound.render(exposures)
end
end
I got LESS to work with Hanami!:D
I was going to post the whole troubleshooting process, but it would be too long, so I'll just reiterate what worked for me. This presupposes that your stylesheet file is called styles.css.less
. The .less suffix is mandatory.
Some links first:
LESS precompiler site: http://lesscss.org/
Direct link to JS file: https://cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js
W3.CSS download page: https://www.w3schools.com/w3css/w3css_downloads.asp
Direct link to main W3.CSS stylesheet: https://www.w3schools.com/w3css/4/w3.css
The setup:
Install therubyracer and less gems:
gem install therubyracer
gem install less
Put the following lines in the Gemfile
file:
gem 'therubyracer'
gem 'less'
In the application.html.erb
file of your app, put the following lines:<%= stylesheet 'styles' %>
(without .css.less suffixes!!!) after the other stylesheets
and<%= javascript 'less.min' %>
(with or without the .js suffix) just before the end of the body.
Note that if you use a CDN, you will likely have to modify the Content Security Policy to allow access.
Put the styles.css.less
file (with the .css.less suffixes) in your apps/<YourApp>/assets/stylesheets
folder and the less.min.js
(with the .js suffix) in your apps/<YourApp>/assets/javascripts
folder (if you're using it locally).
That's it!
The use:
If you use other stylesheets and want to use their classes in mixins, you first need to import them. In the styles.css.less
file, add the following line at the beginning (the example is for the W3.CSS stylesheet):
@import (less) "w3.css";
Then you can do the following, for example:
.tmsr-card-list-item-link-index{
.w3-padding();
}
select {
.w3-select()
}
.tmsr-form-row{
.w3-section();
}
.tmsr-form-row:extend(.w3-row-padding all){}
.tmsr-form-field2:extend(.w3-row-padding, .w3-col, .w3-half all){}
Note, the ":extend" pseudo-class and the "all" keyword with the last two entries. The ":extend" pseudo-class basically extends your class with the W3.CSS class. The "all" keywords means that it will find all instances. In principle, I think you could do all entries with ":extend", but I haven't tested it. The reason for both types of entries is because some classes break LESS. Which ones you'll have to figure out for yourself.
Anyway, it would be nice if someone could independently MTC this, to make sure nothing else on my setup affected this. I tried this twice and it worked.
Other thant that, happy preprocessing!:D
When implementing a destroy action in my controller's code using redirect_to keeps the original i.e. DELETE HTTP method for redirection. Is it an expected behaviour?
ClientRepository.new.delete(params[:id])
redirect_to routes.clients_index_path
HTTP/1.1 DELETE 302 127.0.0.2 /admin/clients/4 5 {"id"=>"4"} 0.019853
HTTP/1.1 DELETE 405 127.0.0.2 /admin/clients - {} 0.007363
I ended up with using halt 200 in the controller's code instead of redirect_to and doing a redirection from JS
[notification] [INFO] [2019-11-28 10:03:20 +0100] HTTP/1.1 DELETE 302 ::1 /notifications/alerts/373 5 {"_method"=>"DELETE", "_csrf_token"=>"f352a44fe416edbf1f2c4bf1f13773c99f6edf9c30012d15bac14db7003c10be", "id"=>"373"} 0.045338
[notification] [INFO] [2019-11-28 10:03:20 +0100] (0.000604s) SELECT "id", "topic", "criterion", "action", "created_at", "updated_at", "name" FROM "alert_rules" ORDER BY "alert_rules"."id"
[notification] [INFO] [2019-11-28 10:03:20 +0100] HTTP/1.1 GET 200 ::1 /notifications/alerts 4629 {} 0.032162