diff --git a/Gemfile b/Gemfile index 0efc113..006de6d 100644 --- a/Gemfile +++ b/Gemfile @@ -3,55 +3,19 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '3.1.2' -# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem 'rails', '~> 7.0.4' - -# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem 'sprockets-rails' - -# Use sqlite3 as the database for Active Record - -# Use the Puma web server [https://github.com/puma/puma] gem 'puma', '~> 5.0' - -# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails] gem 'jsbundling-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' - -# Bundle and process CSS [https://github.com/rails/cssbundling-rails] gem 'cssbundling-rails' - -# Build JSON APIs with ease [https://github.com/rails/jbuilder] gem 'jbuilder' - -# Use Redis adapter to run Action Cable in production -# gem "redis", "~> 4.0" - -# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] -# gem "kredis" - -# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] - -# Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', require: false - -# Use Sass to process CSS -# gem "sassc-rails" - -# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] gem 'image_processing', '~> 1.2' group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem 'byebug' gem 'debug', platforms: %i[mri mingw x64_mingw] gem 'factory_bot_rails' @@ -60,19 +24,11 @@ group :development, :test do end group :development do - # Use console on exceptions pages [https://github.com/rails/web-console] gem 'web-console' - - # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] - # gem "rack-mini-profiler" - - # Speed up commands on slow machines / big apps [https://github.com/rails/spring] - # gem "spring" gem 'faker' end group :test do - # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] gem 'capybara' gem 'database_cleaner-active_record', '~> 2.1.0' gem 'rails-controller-testing' diff --git a/Gemfile.lock b/Gemfile.lock index b1f399d..aef8972 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -163,7 +163,7 @@ GEM nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) orm_adapter (0.5.0) - pagy (6.1.0) + pagy (6.2.0) parallel (1.23.0) parser (3.2.2.4) ast (~> 2.4.1) diff --git a/app/assets/images/flags.png b/app/assets/images/flags.png index cb57957..9b80429 100644 Binary files a/app/assets/images/flags.png and b/app/assets/images/flags.png differ diff --git a/app/assets/stylesheets/application.bootstrap.scss b/app/assets/stylesheets/application.bootstrap.scss index cc96de0..4fe5160 100644 --- a/app/assets/stylesheets/application.bootstrap.scss +++ b/app/assets/stylesheets/application.bootstrap.scss @@ -302,6 +302,10 @@ body { background-position: -1px -17px; } +.be-flag { + background-position: -1px -34px; +} + .nav { .flag { position: relative; diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index ef3a643..4235507 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -15,6 +15,7 @@ def new def create @article = Article.new(article_params) + @article.images.attach(params[:article][:images]) if params[:article][:images].present? if @article.save redirect_to article_path(@article), notice: t('notice.create.success') @@ -25,6 +26,8 @@ def create def update if @article.update(article_params) + @article.images.attach(params[:article][:images]) if params[:article][:images].present? + redirect_to article_path(@article), notice: t('notice.update.success') else render :edit, status: :unprocessable_entity @@ -46,6 +49,6 @@ def set_article def article_params params.require(:article).permit(I18n.available_locales.map do |l| [:"name_#{Mobility.normalize_locale(l)}", :"description_#{Mobility.normalize_locale(l)}"] - end.flatten, images: []) + end.flatten, :images) end end diff --git a/app/models/article.rb b/app/models/article.rb index a875593..b8acf10 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -10,6 +10,5 @@ class Article < ApplicationRecord has_many_attached :images validates :name, presence: true, length: { minimum: 3, maximum: 250 } - validates :description, presence: true, length: { minimum: 5 } validates :images, presence: true end diff --git a/app/views/articles/_form.html.erb b/app/views/articles/_form.html.erb index a38ce1a..9bdef56 100644 --- a/app/views/articles/_form.html.erb +++ b/app/views/articles/_form.html.erb @@ -1,6 +1,6 @@ <%= form_with(model: article, data: { turbo: false }, class: 'form-width-avg') do |form| %> <% if article.errors.any? %> -
+

<%= t('.errors') %>