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 %>
+
+ <% end %>
+
- <% end %>
-
-
+
+ <% end %>
+ <% end %>
<% end %>
@@ -65,10 +71,11 @@
<% @advert.limit(2).each do |advert| %>
-
+
<%= image_tag(advert.desk_image, class: "lg:max-w-[300px] md:max-w-[250px]") %>
+
Desktop
<% end %>
<% @advert.limit(1).each do |advert| %>
diff --git a/db/migrate/20230719222935_create_memberships.rb b/db/migrate/20230719222935_create_memberships.rb
new file mode 100644
index 000000000..e1a1d7731
--- /dev/null
+++ b/db/migrate/20230719222935_create_memberships.rb
@@ -0,0 +1,14 @@
+class CreateMemberships < ActiveRecord::Migration[7.0]
+ def change
+ create_table :memberships do |t|
+ t.string :type_of_membership
+ t.string :title
+ t.string :country
+ t.date :date_of_birth
+ t.string :email
+ t.integer :phone_number
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2bb90df5c..09ef951fc 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.0].define(version: 2023_07_11_124426) do
+ActiveRecord::Schema[7.0].define(version: 2023_07_19_222935) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -68,6 +68,17 @@
t.index ["user_id"], name: "index_clubs_on_user_id"
end
+ create_table "memberships", force: :cascade do |t|
+ t.string "type_of_membership"
+ t.string "title"
+ t.string "country"
+ t.date "date_of_birth"
+ t.string "email"
+ t.integer "phone_number"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "news", force: :cascade do |t|
t.string "type_of_news"
t.string "header_news"
@@ -93,7 +104,6 @@
create_table "products", force: :cascade do |t|
t.text "name"
t.string "description"
- t.string "size"
t.integer "price"
t.string "photo_product"
t.datetime "created_at", null: false
@@ -127,6 +137,7 @@
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
+ t.integer "role", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
diff --git a/test/fixtures/memberships.yml b/test/fixtures/memberships.yml
index 76b4d942d..3b21a1774 100644
--- a/test/fixtures/memberships.yml
+++ b/test/fixtures/memberships.yml
@@ -4,16 +4,14 @@ one:
type_of_membership: MyString
title: MyString
country: MyString
- date_of_birth: MyString
+ data_of_birth: 2023-07-20
email: MyString
- phone_number: MyString
- photo: MyString
+ phone_number: 1
two:
type_of_membership: MyString
title: MyString
country: MyString
- date_of_birth: MyString
+ data_of_birth: 2023-07-20
email: MyString
- phone_number: MyString
- photo: MyString
+ phone_number: 1