diff --git a/app/controllers/advert_controller.rb b/app/controllers/advert_controller.rb index 7d6f478b8..491c0336b 100644 --- a/app/controllers/advert_controller.rb +++ b/app/controllers/advert_controller.rb @@ -36,6 +36,6 @@ def destroy private def advert_params - params.permit(:type_of_advert, :header_advert, :mobile_image, :desk_image, :user_id) + params.require(:advert).permit(:type_of_advert, :header_advert, :mobile_image, :desk_image, :user_id) end end diff --git a/app/controllers/cart_controller.rb b/app/controllers/cart_controller.rb index 5b0838fad..593ba3ebe 100644 --- a/app/controllers/cart_controller.rb +++ b/app/controllers/cart_controller.rb @@ -2,7 +2,7 @@ class CartController < ApplicationController before_action :authenticate_user!, except: %i[show add remove] def show - @render_cart = false + @render_cart = true end def add diff --git a/app/controllers/club_controller.rb b/app/controllers/club_controller.rb index 9c2c8cbaa..13150ea2e 100644 --- a/app/controllers/club_controller.rb +++ b/app/controllers/club_controller.rb @@ -2,20 +2,24 @@ class ClubController < ApplicationController before_action :authenticate_user!, except: %i[index show] def index - @clubs = Club.all.order('created_at DESC') + @club = Club.all.order('created_at DESC') end def show - @clubs = Club.find(params[:id]) + @club = Club.find(params[:id]) + end + + def new + @club = Club.new end def create - @clubs = Club.new(clubs_params) - @clubs.user_id = current_user.id + @club = Club.new(club_params) + @club.user_id = current_user.id respond_to do |format| - if @clubs.save - format.html { redirect_to club_index_path(@clubs), notice: 'News was successfully created.' } + if @club.save + format.html { redirect_to club_index_path(@club), notice: 'News was successfully created.' } else format.html { redirect_to club_index_path, notice: 'Failure' } end @@ -23,15 +27,15 @@ def create end def edit - @clubs = Club.find(params[:id]) + @club = Club.find(params[:id]) end def update - @clubs = Club.find(params[:id]) - @clubs.user_id = current_user.id + @club = Club.find(params[:id]) + @club.user_id = current_user.id respond_to do |format| - if @clubs.update(clubs_params) - format.html { redirect_to club_index_path(@clubs), notice: 'Clubs was successfully updated.' } + if @club.update(club_params) + format.html { redirect_to club_index_path(@club), notice: 'Clubs was successfully updated.' } else format.html { redirect_to club_index_path, notice: 'Failure' } end @@ -39,9 +43,9 @@ def update end def destroy - @clubs = Club.find(params[:id]) - @clubs.user_id = current_user.id - @clubs.delete + @club = Club.find(params[:id]) + @club.user_id = current_user.id + @club.delete respond_to do |format| format.html { redirect_to club_index_path, notice: 'News was successfully deleted.' } @@ -50,7 +54,7 @@ def destroy private - def clubs_params - params.permit(:header, :body, :photo, :user_id) + def club_params + params.require(:club).permit(:header, :body, :photo, :user_id) end end diff --git a/app/controllers/membership_controller.rb b/app/controllers/membership_controller.rb index 478d61a23..a1894c29e 100644 --- a/app/controllers/membership_controller.rb +++ b/app/controllers/membership_controller.rb @@ -1,5 +1,5 @@ class MembershipController < ApplicationController - before_action :authenticate_user!, except: [:index] + before_action :authenticate_user!, except: %i[index show new create] def index; end @@ -33,6 +33,6 @@ def destroy private def membership_params - params.permit(:type_of_membership, :title, :country, :date_of_birth, :email, :phone_number, :photo) + params.permit(:type_of_membership, :title, :country, :date_of_birth, :email, :phone_number) end end diff --git a/app/views/advert/new.html.erb b/app/views/advert/new.html.erb index 61f1163cf..1522205d0 100644 --- a/app/views/advert/new.html.erb +++ b/app/views/advert/new.html.erb @@ -1,4 +1,4 @@ -<%= form_with model: @adverts, url: advert_index_url, method: :post, data: { turbo: false }, local: true do |f| %> +<%= form_with model: @advert, url: advert_index_url, method: :post, data: { turbo: false }, local: true do |f| %>
diff --git a/app/views/cart/show.html.erb b/app/views/cart/show.html.erb index e3081cf20..039394ba0 100644 --- a/app/views/cart/show.html.erb +++ b/app/views/cart/show.html.erb @@ -14,10 +14,8 @@
-
-

Shopping cart

+
+

Items Loaded

<%= @cart.orderables.count %> Items

@@ -43,8 +41,9 @@ <%= orderable.quantity %> <%= orderable.product.price %> - <%= form_with(url: cart_remove_path) do |f| %> <%= - f.hidden_field :id, value: orderable.id %> <%= f.submit "X" %> + <%= form_with(url: cart_remove_path) do |f| %> + <%= f.hidden_field :id, value: orderable.id %> + <%= f.submit "X" %> <% end %> diff --git a/app/views/club/_form.html.erb b/app/views/club/_form.html.erb index 5a1a775a6..2df12b9f6 100644 --- a/app/views/club/_form.html.erb +++ b/app/views/club/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_with model: @clubs, url: club_index_path, method: :club, data: { turbo: false }, local: true do |f| %> +<%= form_with model: @club, url: club_index_path, method: :club, data: { turbo: false }, local: true do |f| %>

diff --git a/app/views/club/index.html.erb b/app/views/club/index.html.erb index 464b60ba0..981da4560 100644 --- a/app/views/club/index.html.erb +++ b/app/views/club/index.html.erb @@ -4,7 +4,7 @@ <%=link_to "Add Club & History", new_club_path, class: "normal-case border-2 border-[#fff] hover:bg-[#fff] font-normal lg:text-2xl md:text-xl sm:text-sm sm:text-xl text-white hover:text-[#FAE115] p-2 rounded-full mb-2" %> <% end %>

-<% @clubs.each do |club| %> +<% @club.each do |club| %>

diff --git a/app/views/club/show.html.erb b/app/views/club/show.html.erb index 6ec791d6c..d4bb444d8 100644 --- a/app/views/club/show.html.erb +++ b/app/views/club/show.html.erb @@ -1,9 +1,9 @@
- CLUB & HISTORY | <%= @clubs.header %> + CLUB & HISTORY | <%= @club.header %>
- <%= image_tag(@clubs.photo) %> - <%= @clubs.body %> + <%= image_tag(@club.photo) %> + <%= @club.body %>
diff --git a/app/views/home/_landing.html.erb b/app/views/home/_landing.html.erb index 0dc225f42..000c6bd5a 100644 --- a/app/views/home/_landing.html.erb +++ b/app/views/home/_landing.html.erb @@ -19,7 +19,8 @@

<%= news.type_of_news %>
-

+ +

<%= news.header_news %>

<%= link_to news_path(news.id) do %> @@ -32,30 +33,35 @@
<% end %> - <% @news.limit(4).each_with_index do |news, index| %> - <% if index == 0 %> - <%# Handle the last item separately %> - <% else %> - <% @news.length - index %> -
- -
- <%= image_tag(news.image, class: "w-[300px] h-[200px]") %> -
-
- <%= news.type_of_news %> -
-

- <%= news.header_news %>. -

- <%= link_to news_path(news.id) do %> -
- Read More - +
+ + <% @news.limit(4).each_with_index do |news, index| %> + <% if index == 0 %> + <%# Handle the last item separately %> + <% else %> + <% @news.length - index %> +
+ +
+ <%= image_tag(news.image, class: "h-[200px] w-full") %> +
+
+ <%= news.type_of_news %> +
+

+ <%= news.header_news %>. +

+ <%= link_to news_path(news.id) do %> +
+ Read More + +
+ <% end %> +
- <% end %> -
-
+
+ <% end %> + <% end %>
<% end %> @@ -65,10 +71,11 @@
<% @advert.limit(2).each do |advert| %> -