0
0
Ruby on Railsframework~10 mins

Strong parameters in Ruby on Rails - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to permit the :name attribute in strong parameters.

Ruby on Rails
params.require(:user).permit([1])
Drag options to blanks, or click blank then click option'
A:name
B:email
C:password
D:age
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use a symbol (missing colon).
Permitting the wrong attribute.
2fill in blank
medium

Complete the code to require the :article parameter in strong parameters.

Ruby on Rails
params.[1](:article).permit(:title, :content)
Drag options to blanks, or click blank then click option'
Afetch
Ballow
Cpermit
Drequire
Attempts:
3 left
💡 Hint
Common Mistakes
Using permit instead of require.
Using a non-existent method like allow.
3fill in blank
hard

Fix the error in the strong parameters method to permit :title and :body.

Ruby on Rails
def article_params
  params.require(:article).[1](:title, :body)
end
Drag options to blanks, or click blank then click option'
Arequire
Bpermit
Callow
Dfetch
Attempts:
3 left
💡 Hint
Common Mistakes
Using require twice.
Using a non-existent method like allow.
4fill in blank
hard

Fill both blanks to permit :email and :password inside the user_params method.

Ruby on Rails
def user_params
  params.[1](:user).[2](:email, :password)
end
Drag options to blanks, or click blank then click option'
Arequire
Bpermit
Cfetch
Dallow
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of require and permit.
Using incorrect method names.
5fill in blank
hard

Fill all three blanks to permit nested attributes :name, :email, and :profile_attributes with :age inside strong parameters.

Ruby on Rails
def user_params
  params.[1](:user).[2](:name, :email, [3]: [:age])
end
Drag options to blanks, or click blank then click option'
Arequire
Bpermit
Cprofile_attributes
Dfetch
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to permit nested attributes properly.
Using fetch instead of require.