Hi all, I''d like to update an attribute in a model via an external POST request. The external request is coming from an iOS iPhone application but I imagine this is not relevant. If I have a model App and it has the following attributes... App apple_identifier :integer popularity :integer I imagine I need an update reference in routes.rb like this.. map.resources :apps, :only => [:index, :show, :update] I then have the following in routes PUT /apps/:id(.:format) {:action=>"update", :controller=>"apps"} So what might the apps_controller update action look like to receive the request and update the popularity count by one...I pretty much think I can solve that myself really I just want to know my thinking it on the right lines. One thing, rake routes says PUT - is that the same as post? What would the URL look like that I ask my iOS dev for, is it as simple as what follows - any gotchas? I imagine...(POST to...) http://server.com/apps/456 def update find App record 456 and update it''s popularity count end Is it really that simple ? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Update to this..... Transpires that we''d like to use the apple_identifier in the URL to do the update rather than the more standard rails db App.id. So the URL submitted to do the update could look more like this. POST to http://server.com/apps?apple_identifier=6383940&incremental_update=1 Where the 6383940 is the apple_identifier I wish to update (passed as a parameter and found in the update action). Is this likely to work out? Bb -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Also, slight aside but can I simulate the action of the iOS app submitting the URL with a curl command on my mac or similar. For testing. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 9, 8:49 am, bingo bob <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> So what might the apps_controller update action look like to receive the > request and update the popularity count by one...I pretty much think I > can solve that myself really I just want to know my thinking it on the > right lines. > > One thing, rake routes says PUT - is that the same as post? >Nope. PUT and POST are two different methods> What would the URL look like that I ask my iOS dev for, is it as simple > as what follows - any gotchas? > > I imagine...(POST to...)http://server.com/apps/456 > > def update > find App record 456 and update it''s popularity count > end > > Is it really that simple ? >sounds about right. Fred> -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.