I can''t make it work. <%= text_field_tag :friend %> <%= observe_field :friend, :url => friendships_url, :on => :click %> <%= javascript_include_tag :defaults %> Raises the error:Can''t find variable Form. The generated html is: <input id="friend" name="friend" type="text" /> <script type="text/javascript"> //<![CDATA[ new Form.Element.EventObserver(''friend'', function(element, value) {new Ajax.Request(''http://mysite.com/friendships'', {asynchronous:true, evalScripts:true, parameters:value + ''&authenticity_token='' + encodeURIComponent(''...edited...'')})}) //]]> </script> -- Posted via http://www.ruby-forum.com/.
The: <%= javascript_include_tag :defaults %> Should appear BEFORE the: <%= observe_field :friend, :url => friendships_url, :on => :click %> It''s usually placed at your page''s <header> section. - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Sun, Jun 14, 2009 at 6:18 PM, Fernando Perez<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I can''t make it work. > > <%= text_field_tag :friend %> > > <%= observe_field :friend, :url => friendships_url, :on => :click %> > > <%= javascript_include_tag :defaults %> > > > Raises the error:Can''t find variable Form. > > The generated html is: > > <input id="friend" name="friend" type="text" /> > > <script type="text/javascript"> > //<![CDATA[ > new Form.Element.EventObserver(''friend'', function(element, value) {new > Ajax.Request(''http://mysite.com/friendships'', {asynchronous:true, > evalScripts:true, parameters:value + ''&authenticity_token='' + > encodeURIComponent(''...edited...'')})}) > //]]> > </script> > -- > Posted via http://www.ruby-forum.com/. > > > >
Thanks Mauricio! So stupid of me! -- Posted via http://www.ruby-forum.com/.
Just to save people 1hr of head banging: This DOES NOT WORK: (data is submitted to ApplicationController/index!!! <%= observe_field :friendship_accessibility, :url => friendship_url(friendship), :on => :click, :with => :accessibility %> This works: (all options are compulsory) <%= observe_field :friendship_accessibility, :url => {:controller => ''friendships'', :action => ''update'', :id => friendship}, :on => :click, :with => :accessibility, :method => :update %> Is that a bug? Why can''t the observe_field and Rails routing mechanism recognize the restful route? -- Posted via http://www.ruby-forum.com/.
Do I need to set a respond_to block in the update action of the controller for rjs? I don''t understand what''s missing, and the rails api is rather thin on the subject. -- Posted via http://www.ruby-forum.com/.
You don''t have an :update specified on the parameters for observe_field. Assuming you don''t want to render anything, do a render :nothing=>true in the controller. On Jun 15, 2:53 am, Fernando Perez <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Do I need to set a respond_to block in the update action of the > controller for rjs? I don''t understand what''s missing, and the rails api > is rather thin on the subject. > -- > Posted viahttp://www.ruby-forum.com/.
Mukund wrote:> You don''t have an :update specified on the parameters for > observe_field. Assuming you don''t want to render anything, do a > render :nothing=>true in the controller.The problem is that it''s ApplicationController#index that processes the submitted data. I don''t understand why. The url is correctly formed. -- Posted via http://www.ruby-forum.com/.