ruby - Rails: Link changes one attribute and then goes back -


Train newbies here.

I have a list of items , which is a status represented by an integer (its just 1 = active 0 = inactive) .

The link to change the status of the item that is next to each item , it will look like this:

One good object - enabled

Another beautiful object - disable

I do not think how to link the link I just click on a user link I want to click and then page refresh and item are updated.

This does not work:

  & lt;% = link_to "Enable" ,: Controller => "Item" ,: verb = & gt; "Update" ,: Status = & gt; 1%>  

If you have default Rail Controller applied, then

  & lt;% = link_to "Enable" ,: Admin = & gt; "Item" ,: verb = & gt; "Update" ,: Status = & gt; 1%>  

is not working because the call in the update action calls

  @ item.update_attributes (params [: item])  < / Pre> 

and going as a status controller

  params [: status]  

In addition to updating the method Put should be.

Try changing the link like this:

  & lt;% = link_to "Enable" ,: Admin = & gt; "Item" ,: verb = & gt; "Update" ,: Method = & gt; : Put: item = & gt; {: Condition = & gt; 1}%>  

Comments