I’ve spent all day trying to get Devise and nested attributes to play nicely together.

updating erb-11updating erb-20updating erb-11

The first step to achieving this is to alter our routes file: This checks to see if the user is attempting to update the email or password field.

If so, and if validation passes, then it calls update_with_password which will carry out the necessary password checks, otherwise it calls update_attributes, which doesn't. The code for this tutorial is on Git Hub: https://github.com/hibbard-eu/authentication-with-devise-and-cancancan Reference: So, this was quite a long post — I hope it proves useful for people.

) "name", "Buy a necklace"], ["created_at", 2016-07-07 UTC], ["updated_at", 2016-07-07 UTC (2.0ms) commit transaction Redirected to Completed 200 OK in 4ms (Active Record: 2.3ms) Started GET "/tasks" for ::1 at 2016-07-07 -0700 Processing by Tasks Controller#index as HTML Rendering tasks/erb within layouts/application Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."complete" = ?

"complete", true Rendered collection of tasks/_erb [2 times] (1.2ms) Rendered tasks/erb within layouts/application (12.0ms) Completed 200 OK in 36ms (Views: 33.6ms | Active Record: 0.5ms) Started POST "/tasks" for ::1 at 2016-07-07 -0700 Processing by Tasks Controller#create as JS Parameters: (0.1ms) begin transaction SQL (0.3ms) INSERT INTO "tasks" ("name", "created_at", "updated_at") VALUES (? "id", 13 (0.5ms) commit transaction Redirected to Completed 302 Found in 3ms (Active Record: 1.0ms) Started GET "/tasks" for ::1 at 2016-07-07 -0700 Processing by Tasks Controller#index as HTML Rendering tasks/erb within layouts/application Task Load (0.1ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."complete" = ?

Note that the controller method has to respond in this format also, otherwise is of no use. It's possible if you do a full click event, and call $(this) within that function, but otherwise, how do you do it using render js?

How would you do this if the target element wasn't a unique element with an id, but instead if there's multiple of them with the same class name, and you want to target just that one. Cause you may want to do something on the back end in the controller or model before executing the front end Type: 'script'` so I can capture the Javascript behaviour returned by the controller, and/or complementing it with the logic in the success function.There are a few things that we'll need to do in order to implement this behavior. The todo app will work without any ajax, meaning the page will be refreshed due to redirect when you delete, create or update tasks. Create erb: Started POST "/tasks" for ::1 at 2016-07-07 -0700 Processing by Tasks Controller#create as JS Parameters: (0.1ms) begin transaction SQL (0.3ms) INSERT INTO "tasks" ("name", "created_at", "updated_at") VALUES (? "name", "Buy a puppy"], ["created_at", 2016-07-07 UTC], ["updated_at", 2016-07-07 UTC (0.4ms) commit transaction Rendering tasks/erb Rendered tasks/_erb (1.2ms) Rendered tasks/erb (2.9ms) Completed 200 OK in 10ms (Views: 6.1ms | Active Record: 0.7ms) Started DELETE "/tasks/13" for ::1 at 2016-07-07 -0700 Processing by Tasks Controller#destroy as HTML Parameters: Task Load (0.2ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = ? "id", 13], ["LIMIT", 1 (0.0ms) begin transaction SQL (0.3ms) DELETE FROM "tasks" WHERE "tasks"."id" = ?You'll practice updating your cookbook, uploading it to the Chef server, and seeing the changes appear on your node.You already learned how to use the template resource to reference the HTML file for your home page.If you're curious about which HTTP verb should be selected, consider the following: we're sending data to the server, so we know it's not page, it will now display the form, but you may have noticed a pretty big flaw.

||

How would you do this if the target element wasn't a unique element with an id, but instead if there's multiple of them with the same class name, and you want to target just that one. Cause you may want to do something on the back end in the controller or model before executing the front end Type: 'script'` so I can capture the Javascript behaviour returned by the controller, and/or complementing it with the logic in the success function.

There are a few things that we'll need to do in order to implement this behavior.

The todo app will work without any ajax, meaning the page will be refreshed due to redirect when you delete, create or update tasks. Create erb: Started POST "/tasks" for ::1 at 2016-07-07 -0700 Processing by Tasks Controller#create as JS Parameters: (0.1ms) begin transaction SQL (0.3ms) INSERT INTO "tasks" ("name", "created_at", "updated_at") VALUES (? "complete", false Rendered collection of tasks/_erb [6 times] (5.2ms) Task Load (0.2ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."complete" = ? ) "name", "Buy a puppy"], ["created_at", 2016-07-07 UTC], ["updated_at", 2016-07-07 UTC (0.4ms) commit transaction Rendering tasks/erb Rendered tasks/_erb (1.2ms) Rendered tasks/erb (2.9ms) Completed 200 OK in 10ms (Views: 6.1ms | Active Record: 0.7ms) Started DELETE "/tasks/13" for ::1 at 2016-07-07 -0700 Processing by Tasks Controller#destroy as HTML Parameters: Task Load (0.2ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = ? "id", 13], ["LIMIT", 1 (0.0ms) begin transaction SQL (0.3ms) DELETE FROM "tasks" WHERE "tasks"."id" = ?

You'll practice updating your cookbook, uploading it to the Chef server, and seeing the changes appear on your node.

You already learned how to use the template resource to reference the HTML file for your home page.

If you're curious about which HTTP verb should be selected, consider the following: we're sending data to the server, so we know it's not page, it will now display the form, but you may have noticed a pretty big flaw.

||

How would you do this if the target element wasn't a unique element with an id, but instead if there's multiple of them with the same class name, and you want to target just that one. Cause you may want to do something on the back end in the controller or model before executing the front end Type: 'script'` so I can capture the Javascript behaviour returned by the controller, and/or complementing it with the logic in the success function.

There are a few things that we'll need to do in order to implement this behavior.

The todo app will work without any ajax, meaning the page will be refreshed due to redirect when you delete, create or update tasks. Create erb: Started POST "/tasks" for ::1 at 2016-07-07 -0700 Processing by Tasks Controller#create as JS Parameters: (0.1ms) begin transaction SQL (0.3ms) INSERT INTO "tasks" ("name", "created_at", "updated_at") VALUES (? "complete", false Rendered collection of tasks/_erb [6 times] (5.2ms) Task Load (0.2ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."complete" = ? ) "name", "Buy a puppy"], ["created_at", 2016-07-07 UTC], ["updated_at", 2016-07-07 UTC (0.4ms) commit transaction Rendering tasks/erb Rendered tasks/_erb (1.2ms) Rendered tasks/erb (2.9ms) Completed 200 OK in 10ms (Views: 6.1ms | Active Record: 0.7ms) Started DELETE "/tasks/13" for ::1 at 2016-07-07 -0700 Processing by Tasks Controller#destroy as HTML Parameters: Task Load (0.2ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = ? "id", 13], ["LIMIT", 1 (0.0ms) begin transaction SQL (0.3ms) DELETE FROM "tasks" WHERE "tasks"."id" = ?

You'll practice updating your cookbook, uploading it to the Chef server, and seeing the changes appear on your node.

]]