Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
aoz-003
Commits
aea92940
Commit
aea92940
authored
May 19, 2017
by
Chrysanthi Lagodimou
Browse files
nested attributes in controllers concern
parent
76565cdc
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/controllers/clients_controller.rb
View file @
aea92940
class
ClientsController
<
ApplicationController
include
NestedAttributes
before_action
:set_client
,
only:
[
:show
,
:edit
,
:update
,
:destroy
]
def
index
...
...
@@ -59,19 +61,11 @@ class ClientsController < ApplicationController
end
def
client_params
params
.
require
(
:client
).
permit
(
:id
,
:first_name
,
:last_name
,
:date_of_birth
,
:nationality
,
:permit
,
:gender
,
:street
,
:zip
,
:city
,
:phone
,
:email
,
:goals
,
:education
,
:hobbies
,
params
.
require
(
:client
).
permit
(
:id
,
:first_name
,
:last_name
,
:date_of_birth
,
:nationality
,
:permit
,
:gender
,
:street
,
:zip
,
:city
,
:phone
,
:email
,
:goals
,
:education
,
:hobbies
,
:interests
,
:state
,
:comments
,
:competent_authority
,
:involved_authority
,
:user_id
,
language_skills_attributes:
[
:id
,
:language
,
:level
,
:_destroy
],
relatives_attributes:
[
:id
,
:first_name
,
:last_name
,
:date_of_birth
,
:relation
,
:_destroy
],
schedules_attributes:
[
:id
,
:day
,
:time
,
:available
]
)
language_skills_attributes:
language_skills_attributes
,
relatives_attributes:
relatives_attributes
,
schedules_attributes:
schedules_attributes
)
end
end
app/controllers/concerns/nested_attributes.rb
0 → 100644
View file @
aea92940
module
NestedAttributes
extend
ActiveSupport
::
Concern
included
do
def
language_skills_attributes
[
:id
,
:language
,
:level
,
:_destroy
]
end
def
relatives_attributes
[
:id
,
:first_name
,
:last_name
,
:date_of_birth
,
:relation
,
:_destroy
]
end
def
schedules_attributes
[
:id
,
:day
,
:time
,
:available
]
end
end
end
app/controllers/volunteers_controller.rb
View file @
aea92940
class
VolunteersController
<
ApplicationController
include
NestedAttributes
before_action
:set_volunteer
,
only:
[
:show
,
:edit
,
:update
,
:destroy
]
def
index
...
...
@@ -48,14 +49,8 @@ class VolunteersController < ApplicationController
:education
,
:motivation
,
:experience
,
:expectations
,
:strengths
,
:skills
,
:interests
,
:state
,
:duration
,
:man
,
:woman
,
:family
,
:kid
,
:sport
,
:creative
,
:music
,
:culture
,
:training
,
:german_course
,
:adults
,
:teenagers
,
:children
,
:region
,
language_skills_attributes:
[
:id
,
:language
,
:level
,
:_destroy
],
relatives_attributes:
[
:id
,
:first_name
,
:last_name
,
:date_of_birth
,
:relation
,
:_destroy
],
schedules_attributes:
[
:id
,
:day
,
:time
,
:available
])
language_skills_attributes:
language_skills_attributes
,
relatives_attributes:
relatives_attributes
,
schedules_attributes:
schedules_attributes
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment