Skip to content

Commit 1cee66a

Browse files
committed
Turned off csrf and changed some files
1 parent 48e59ae commit 1cee66a

File tree

8 files changed

+21
-186
lines changed

8 files changed

+21
-186
lines changed

app/admin/admin_users.rb

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
end
2222

2323
show do |admin_user|
24+
panel 'Avatar' do
25+
if admin_user.avatar.attached?
26+
image_tag admin_user.avatar
27+
else
28+
para 'No avatar'
29+
end
30+
end
31+
2432
panel 'Content' do
2533
admin_user.body
2634
end
@@ -57,6 +65,7 @@
5765
f.input :email
5866
f.input :name
5967
f.input :body
68+
f.input :avatar, as: :file
6069
f.input :password
6170
f.input :password_confirmation
6271
end

app/admin/comments.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
filter :published
3333
filter :body
3434
filter :post
35-
# filter :user, as: :select, collection: User.all.map { |u| [u.email, u.id] }
35+
filter :user, as: :select, collection: User.all.map { |u| [u.email, u.id] }
3636
filter :updated_at
3737
filter :created_at
3838

app/admin/likes.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
actions
1111
end
1212

13-
# filter :user, as: :select, collection: User.all.map { |u| [u.email, u.id] }
13+
filter :user, as: :select, collection: User.all.map { |u| [u.email, u.id] }
1414
filter :record_type
1515
filter :created_at
1616
filter :updated_at
@@ -19,7 +19,8 @@
1919
f.inputs do
2020
f.semantic_errors
2121
f.input :user, collection: User.all.map { |u| [u.email, u.id] }
22-
f.input :record, collection: Post.all
22+
f.input :record_type, as: :hidden, input_html: { value: 'Post' }
23+
f.input :record, collection: Post.all.map { |u| [u.title, u.id] }
2324
end
2425
f.actions
2526
end
-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
module Blog
22
class BaseController < ApplicationController
33
layout 'blog/application'
4-
5-
# before_action :configure_permitted_parameters, if: :devise_controller?
6-
7-
# private
8-
9-
# def configure_permitted_parameters
10-
# devise_parameter_sanitizer.permit(:sign_up, keys: %i[name avatar body])
11-
# devise_parameter_sanitizer.permit(:account_update, keys: %i[name avatar body])
12-
# end
134
end
145
end

app/controllers/blog/comments_controller.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ def create
1515

1616
private
1717

18-
def render_not_allowed
19-
render_without_layout('messages', :forbidden, messages: [t('.not_allowed')])
20-
end
21-
2218
def can_create_comment?
2319
Post.find(params[:post_id]).comments_enabled?
2420
end
@@ -29,6 +25,10 @@ def comment_params
2925
.merge(post: Post.find(params[:post_id]), user: current_user)
3026
end
3127

28+
def render_not_allowed
29+
render_without_layout('messages', :forbidden, messages: [t('.not_allowed')])
30+
end
31+
3232
def render_without_layout(partial, status, **locals)
3333
render partial:,
3434
locals:,

app/controllers/blog/likes_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def update
99
else
1010
@post.like(current_user)
1111
end
12-
12+
1313
render partial: 'update', layout: false
1414
end
1515

config/environments/production.rb

+2
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,6 @@
9090

9191
# Do not dump schema after migrations.
9292
config.active_record.dump_schema_after_migration = false
93+
94+
config.action_controller.allow_forgery_protection = false
9395
end

config/locales/en.yml

+1-169
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ en:
44
navbar:
55
home: Home
66
search: Search
7-
87
blog:
98
search:
109
index:
@@ -46,171 +45,4 @@ en:
4645
keywords: '%{name}, profile %{name}, account %{name}, my %{name}, blog'
4746
description: 'Hello everyone! My name is %{name}. It is my official account on %{site_name}.'
4847
likes:
49-
update: 'Likes: %{count}'
50-
admin:
51-
dashboards:
52-
index:
53-
meta:
54-
title: Dashboard
55-
statistics:
56-
meta:
57-
title: Statistics
58-
categories:
59-
edit:
60-
title: 'Edit a category'
61-
meta:
62-
title: 'Edit a category: %{title}'
63-
index:
64-
meta:
65-
title: 'All categories'
66-
table:
67-
number: '#'
68-
title: 'Title'
69-
posts: 'Posts'
70-
meta: 'Meta data'
71-
management: 'Management'
72-
new:
73-
meta:
74-
title: 'Create a new category'
75-
title: 'Create a new category'
76-
posts:
77-
meta:
78-
title: 'All posts from the category: %{title}'
79-
form:
80-
title: 'Name: '
81-
description: 'Description: '
82-
meta: 'Meta data'
83-
meta_description: 'Description: '
84-
meta_keywords: 'Keywords: '
85-
meta_title: 'Title: '
86-
submit: 'Send'
87-
comments:
88-
form:
89-
body: 'Comment: '
90-
publish: 'Published: '
91-
user: 'Choose a user: '
92-
post: 'Choose a post: '
93-
submit: 'Send'
94-
table:
95-
number: '#'
96-
body: 'Comment'
97-
published: 'Published'
98-
user: 'User'
99-
post: 'Post'
100-
management: 'Management'
101-
edit:
102-
title: 'Edit a comment'
103-
meta:
104-
title: 'Edit a comment'
105-
index:
106-
meta:
107-
title: 'All comments'
108-
new:
109-
meta:
110-
title: 'Create a new comment'
111-
title: 'Create a new comment'
112-
pages:
113-
form:
114-
title: 'Name: '
115-
body: 'Content: '
116-
published: 'Published: '
117-
meta_description: 'Description: '
118-
meta_keywords: 'Keywords: '
119-
meta_title: 'Title: '
120-
meta: 'Meta data: '
121-
submit: 'Send'
122-
edit:
123-
title: 'Edit a page'
124-
meta:
125-
title: 'Edit a page: %{title}'
126-
index:
127-
meta:
128-
title: 'All pages'
129-
table:
130-
number: '#'
131-
title: 'Title'
132-
published: 'Published'
133-
meta: 'Meta data'
134-
management: 'Management'
135-
new:
136-
meta:
137-
title: 'Create a new page'
138-
title: 'Create a new page'
139-
panel:
140-
management_links:
141-
show: 'Show'
142-
edit: 'Edit'
143-
delete: 'Destroy'
144-
posts:
145-
form:
146-
title: 'Name: '
147-
description: 'Description: '
148-
body: 'Content: '
149-
published: 'Published: '
150-
comments_enabled: 'Allow commenting on this post: '
151-
category: 'Category: '
152-
meta_description: 'Description: '
153-
meta_keywords: 'Keywords: '
154-
meta_title: 'Title: '
155-
meta: 'Meta data: '
156-
submit: 'Send'
157-
table:
158-
number: '#'
159-
title: 'Title'
160-
published: 'Published'
161-
comments_enabled: 'Comments enabled'
162-
comments: 'Comments'
163-
category: 'Category'
164-
meta: 'Meta data'
165-
management: 'Management'
166-
comments:
167-
meta:
168-
title: 'All comments from the post: %{title}'
169-
edit:
170-
title: 'Edit a post'
171-
meta:
172-
title: 'Edit a post: %{title}'
173-
index:
174-
meta:
175-
title: 'All posts'
176-
new:
177-
meta:
178-
title: 'Create a new post'
179-
title: 'Create a new post'
180-
users:
181-
form:
182-
email: 'Email: '
183-
password: 'Password: '
184-
password_confirmation: 'Password confirmation: '
185-
name: 'Name: '
186-
role: 'Role: '
187-
body: 'Content: '
188-
avatar: 'Avatar: '
189-
submit: 'Send'
190-
comments:
191-
meta:
192-
title: 'All comments from the user: %{name}'
193-
edit:
194-
title: 'Edit a user'
195-
meta:
196-
title: 'Edit a user: %{name}'
197-
index:
198-
meta:
199-
title: 'All users'
200-
table:
201-
number: '#'
202-
email: 'Email'
203-
name: 'Name'
204-
posts: 'Posts'
205-
comments: 'Comments'
206-
management: 'Management'
207-
new:
208-
meta:
209-
title: 'Create a new user'
210-
title: 'Create a new user'
211-
posts:
212-
meta:
213-
title: 'All posts from the user: %{name}'
214-
show:
215-
meta:
216-
title: 'User: %{name}'
48+
update: 'Likes: %{count}'

0 commit comments

Comments
 (0)