- Rails 7.0.2
- stimulus js
- importmaps
- dropzone.js
- direct upload ActiveStorage
This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.
This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.
class BlogEntity < ApplicationRecord | |
belongs_to :city | |
def posts | |
Post.where(blog_entity_id: self.id).order_by({created_at: -1}) | |
end | |
def there_is_a_post_with_url(url) | |
Post.where(url: url).exists? | |
end |
// require materialize.css | |
$(document).on('turbolinks:load', function() { | |
$('.update_form .regular').on('focusout', event => $('.update_form').trigger('submit')); | |
$('.update_form').on('submit', e => { | |
$.ajax(e.target.action, { | |
type: 'PUT', | |
dataType: 'json', | |
data: $(".update_form").serialize(), |
docker run --name postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -p 5432:5432 -d postgres | |
------------------- | |
development: | |
<<: &default | |
adapter: postgresql | |
encoding: unicode | |
database: anything_development | |
username: postgres |
# List all models | |
ActiveRecord::Base.connection.tables.map do |model| | |
model.capitalize.singularize.camelize | |
end | |
# Get all associations of a model | |
User.reflect_on_all_associations |
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
#!/bin/sh | |
# Extract the archive $1 to a directory $2 with the program $3. If the | |
# archive contains a single top-level directory, that directory | |
# becomes $2. Otherwise $2 contains all the files at the root of the | |
# archive. | |
extract () ( | |
set -e | |
archive=$1 | |
case "$archive" in |
Ha uma chamada para a API direto na renderizacao do componente. | |
<vpaginator ref="paginator" :options="$defaultPaginatorConfig" resource_url="/atlas/planejamentos" @update="updateResource"></vpaginator> | |
--------------------------- | |
O script esta assim: | |
<script> |
Headline: | |
"I’m a full-stack software engineer with a focus on education." | |
Bio: | |
"I’m a full-stack software engineer with a focus on education. In my past life, I was a digital media strategist and an international English teacher. From products to interactions, I live for creating joyful experiences and thrive in learning something new. You can say my continued passion for technology and learning led me here. | |
I see problems as opportunities to create and programming as my toolbox. You can often see me wondering out loud about developing better efficiencies on whatever project I am working on. If you are not planning on contacting me about my portfolio, I am also a certified wine taster so we can talk about that too. |
mkdir nameOfProject | |
cd nameOfProject | |
docker run --rm --user "$(id -u):$(id -g)" -v $(pwd):/usr/src -w /usr/src -ti ruby:latest bash | |
gem install rails | |
rails new . --database=postgresql --skip-bundle | |
--------------------- Dockerfile ---------------------- | |
FROM ruby:latest |