-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create task #8
create task #8
Conversation
Adding join table user_tasks.
task = Task.new(task_params) | ||
|
||
if task.save | ||
render_success(TaskSerializer.new(task)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
эта конструкция повторяется во всех контроллерах, думаю можно вынести в метод и передавать в него блок
app/mailers/task_mailer.rb
Outdated
email = User.find(params[:user]).email | ||
@task = Task.find(params[:task]).title | ||
|
||
mail(to: email, subject: 'Task created') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
юзай I18n сразу
belongs_to :user | ||
belongs_to :task | ||
|
||
after_commit :create_task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше использовать сервисы, чтобы избежать подобных коллбеков. коллбеки сложнее тестировать и они менее предсказуемы чем линейный код
app/serializers/task_serializer.rb
Outdated
# frozen_string_literal: true | ||
|
||
class TaskSerializer | ||
include FastJsonapi::ObjectSerializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделай базовый класс и вынеси include в него
app/uploaders/picture_uploader.rb
Outdated
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" | ||
end | ||
|
||
# process scale: [200, 300] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удаляй этот закомментированный код
db/schema.rb
Outdated
end | ||
|
||
create_table "user_tasks", force: :cascade do |t| | ||
t.bigint "user_id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null: false
|
||
# These are extensions that must be enabled in order to support this database | ||
enable_extension "plpgsql" | ||
|
||
create_table "pictures", force: :cascade do |t| | ||
t.string "image" | ||
t.integer "task_id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null: false ?
app/controllers/themes_controller.rb
Outdated
# PATCH /themes/:id | ||
def update | ||
theme = Theme.find(params[:id]) | ||
if theme.update_attributes(theme_params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update
#create
,#update
,#delete
forTheme
,Task
.user_tasks
. (The student can be given a task.). It is possible to add a link between a user and a task:UserTaskController
Issue: #2 Create task