ruby on rails - Railstutorial.org Michael Hartl chapter 9 exercise 3 "should not allow the admin attribute to be edited via the web" -


I have started learning rail, and I got stuck on Chapter 9 third practice.

Exercise looks like this:

  test should not allow "administrator attribute to be edited through the web" log_in_as (@ Other_user) Assert_not @ other_user.admin? Patches: Updates, IDs: @other_users, user: {password: FILL_IN, password_confirmation: FILL_IN, administrator: FILL_IN} assert_not @other_user.FILL_IN.admin? End   

My problem is that the last FIL_IN & gt; & Gt; Assert_not @ other_user.FILL_IN.admin ?

@other_user is taken from stability and looks like this:

  Archer: Name: Sterling Archer Email: duchess@example.gov password_digest: & lt;% = User.digest ('password')%>   

Update action looks like this:

  def update = user = user.find (params [: id]) If @ User.update_attributes (user_params) Flash [: success] = "profile updated" redirect_to @user else render 'edit and end'   

I also created : admin < / code> User_params can be modified at : Administrator param :

  def user_params params.require (: user) .permit (: name,: email,: Password: Password_confirmation, admin) end   

I thought that was correct:

  test " Do not allow to edit from "Log_In_se (@other_user) assert_not @other_user.admin? Patches: Updates, IDs: @other_users, user: {password: @other_ger Password, password_confirmation: @other_user.password_confirmation, administrator: correct} assert_not @ other_user.admin?   

But it seems that the @other_moder is not being modified, so I think the error is at the end.

My answer is wrong, I can not get this test to fail, this is because in the last claim "assert_not @other_user.FILL_IN.admin?"

I do not know what to put in the FILL_IN section I tried to cut FILL_IN but it does not work.

After making changes to the underlying record, you must reload the frequency variable. It will load in new changes.

  assert_not @ other_user.reload.admin?    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -