# Button\_to question

**URL:** <https://www.ruby-forum.com/t/button-to-question/206480>\
**Category:** Rails\
**Created:** [May 2, 2011, 8:05pm UTC](https://www.ruby-forum.com/t/button-to-question/206480 "2011-05-02T20:05:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [May 2, 2011, 8:05pm UTC](https://www.ruby-forum.com/t/button-to-question/206480/1 "2011-05-02T20:05:20Z")

</div>

I have the below model that gets created with create action with  
:running  
field having value of false.

class Portal  
include Mongoid::Document  
field :url, :type =\> String  
field :user, :type =\> String  
field :password, :type =\> String  
field :running, :type =\> Boolean, :default =\> false  
end

Later I want to set :running to true. I want to use the button\_to form  
helper method to set running to true.  
The button is installed in the index view.  
What arguments needs to be passed to the button\_to method?

Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![orlick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/53a042/32.png) [@orlick](https://www.ruby-forum.com/u/orlick)\
**Post date:** [May 2, 2011, 9:11pm UTC](https://www.ruby-forum.com/t/button-to-question/206480/2 "2011-05-02T21:11:29Z")

</div>

On May 2, 7:03pm, Alex K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Later I want to set :running to true. I want to use the button\_to form  
> helper method to set running to true.  
> The button is installed in the index view.  
> What arguments needs to be passed to the button\_to method?

Well you’ll want an action that loads the relevant Portal object and  
updates it and then call button\_to with the routing options for that  
action.

Fred

---

<div class="post-metadata">

**Author:** ![orlick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/53a042/32.png) [@orlick](https://www.ruby-forum.com/u/orlick)\
**Post date:** [May 2, 2011, 10:52pm UTC](https://www.ruby-forum.com/t/button-to-question/206480/3 "2011-05-02T22:52:19Z")

</div>

Ho do I pass the running field with the button\_to method

On Mon, May 2, 2011 at 3:10 PM, Frederick C.  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![orlick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/53a042/32.png) [@orlick](https://www.ruby-forum.com/u/orlick)\
**Post date:** [May 2, 2011, 11:52pm UTC](https://www.ruby-forum.com/t/button-to-question/206480/4 "2011-05-02T23:52:23Z")

</div>

On May 2, 9:50pm, Alex K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ho do I pass the running field with the button\_to method

That depends on how you’ve written the action the button links to.  
if the action looked like

def start  
p = Portal.find(params[:id])  
p.running = true  
p.save!  
end

then you don’t need to pass anything beyond the id of the object that  
needs updating

Fred
