I have a column in the database for called confirmed that is a
tinyint(1).
currently the value is set to 0.
i am trying to use the following function in my controller for
Compounds:
def confirm
@compound = Compound.find(params[:id])
@compound.toggle!(:confirmed)
redirect_to compound_path(@compound)
end
i have my routes like the following:
map.resources :compounds, :collection => { :calculator => :get },
:member => { :confirm => :post }
and this is what the link looks like:
http://domain/compounds/3960/confirm
but for some reason the value of confirmed is not changing. anyone have
any ideas?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi Scott,
Try :put instead of :post on the :member param, like this:
map.resources :compounds, :collection => { :calculator
=> :get }, :member => { :confirm => :put }
Scott Kulik wrote:> I have a column in the database for called confirmed that is a
> tinyint(1).
>
> currently the value is set to 0.
>
> i am trying to use the following function in my controller for
> Compounds:
>
> def confirm
> @compound = Compound.find(params[:id])
> @compound.toggle!(:confirmed)
> redirect_to compound_path(@compound)
> end
>
> i have my routes like the following:
>
> map.resources :compounds, :collection => { :calculator => :get },
> :member => { :confirm => :post }
>
> and this is what the link looks like:
>
> http://domain/compounds/3960/confirm
>
> but for some reason the value of confirmed is not changing. anyone have
> any ideas?
> --
> Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> def confirm > @compound = Compound.find(params[:id]) > @compound.toggle!(:confirmed) > redirect_to compound_path(@compound) > endShouldn''t your confirm method always set the :confirmed flag to true rather than toggling it anyway? Calling confirm on an already confirmed item should remain confirmed right? In this case if confirm were called on a confirmed item it would unconfirm it. It seems that should be a separate operation to me. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Elias Orozco wrote:> Hi Scott, > > Try :put instead of :post on the :member param, like this: > > map.resources :compounds, :collection => { :calculator > => :get }, :member => { :confirm => :put }Elias, i tried put but got this error back: Only put requests are allowed. robert, i think the toggle should toggle the value from 1->0 or 0->1 but i can''t even get it to toggle from 0->1 at the moment. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---