Skip to content

Commit 59cd3fd

Browse files
committed
Змінені стилі, додані дрібні правки, додана посторінкова навігація, виправлена помилка праці пошуку з посторінковою навігацією
1 parent 1b4fbec commit 59cd3fd

File tree

11 files changed

+1549
-145
lines changed

11 files changed

+1549
-145
lines changed

app/controllers/books_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ def set_book
7474

7575
# Never trust parameters from the scary internet, only allow the white list through.
7676
def book_params
77-
params.require(:book).permit(:title, :auth, :zhanr, :pages_qty, :description, :image_url)
77+
params.require(:book).permit(:title, :auth, :zhanr, :pages_qty, :description, :image_url, :mini_description)
7878
end
7979
end

app/models/book.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Book < ApplicationRecord
22

3-
validates :title, :auth, :zhanr, :pages_qty, :description, :image_url, :presence => true
3+
validates :title, :auth, :zhanr, :pages_qty, :description, :image_url, :mini_description, :presence => true
44
def self.search(search)
55
where(['title LIKE ? OR auth LIKE ? OR zhanr LIKE ? OR description LIKE ? ', "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%"])
66

app/views/books/_book.json.jbuilder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
json.extract! book, :id, :title, :auth, :zhanr, :pages_qty, :description, :image_url, :created_at, :updated_at
1+
json.extract! book, :id, :title, :auth, :zhanr, :pages_qty, :description, :image_url, :mini_description, :created_at, :updated_at
22
json.url book_url(book, format: :json)

app/views/books/_form.html.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:label_Z => "Жанр",
66
:label_Q => "Кількість сторінок",
77
:label_D => "Опис",
8+
:label_MD => "Короткий опис",
89
:label_I => "Адреса до картинки",
910
:submit => "Підтвердити"
1011
}
@@ -15,6 +16,7 @@
1516
:label_Z => "Genre",
1617
:label_Q => "Number of pages",
1718
:label_D => "Description",
19+
:label_MD => "Mini description",
1820
:label_I => "Address to the picture",
1921
:submit => "Submit"
2022
}
@@ -25,6 +27,7 @@
2527
:label_Z => "Жанр",
2628
:label_Q => "Количество страниц",
2729
:label_D => "Описание",
30+
:label_MD => "Краткое описание",
2831
:label_I => "Адрес к картинке",
2932
:submit => "Подтвердить"
3033
}
@@ -64,6 +67,11 @@
6467
<%= f.text_field :pages_qty, :class => "form-control" %>
6568
</div>
6669

70+
<div class="form-group">
71+
<label class="col-xs-2 control-label"><%= text[:label_MD] %></label>
72+
<%= f.text_area :mini_description, :class => "form-control" %>
73+
</div>
74+
6775
<div class="form-group">
6876
<label class="col-xs-2 control-label"><%= text[:label_D] %></label>
6977
<%= f.text_area :description, :class => "form-control" %>

app/views/books/index.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
<i class="fa fa-desktop fa-3x"></i>
6565
</div>
6666
<p>
67-
<%= book.description %>
67+
<%= book.mini_description %><br/>
68+
<%= link_to 'Видалити', book, method: :delete, data: { confirm: 'Ви впевнені?' } %>
6869
</p>
69-
7070
</div>
7171
</div>
7272
</div>

db/development.sqlite3

13 KB
Binary file not shown.

db/migrate/20170429130500_create_books.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ def change
66
t.string :zhanr
77
t.string :pages_qty
88
t.text :description
9+
t.text :mini_description
10+
t.integer :likes_qty
11+
t.integer :dislikes_qty
912
t.string :image_url
10-
1113
t.timestamps
1214
end
1315
end

db/schema.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
t.string "zhanr"
1919
t.string "pages_qty"
2020
t.text "description"
21+
t.text "mini_description"
22+
t.integer "likes_qty"
23+
t.integer "dislikes_qty"
2124
t.string "image_url"
22-
t.datetime "created_at", null: false
23-
t.datetime "updated_at", null: false
25+
t.datetime "created_at", null: false
26+
t.datetime "updated_at", null: false
2427
end
2528

2629
create_table "line_items", force: :cascade do |t|

log/development.log

Lines changed: 1527 additions & 136 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
I"~app/assets/stylesheets/application.scss?type=text/css&id=35e15a1cce284e45244954027d061a97bef85c97d52c4f6270aeb409e6d340fc:ET
1+
I"~app/assets/stylesheets/application.scss?type=text/css&id=4ff89ab7ef0ed289feb5b62ae0a3da67bd96f088f999bede7cf21713cf1a4d01:ET

0 commit comments

Comments
 (0)