Lost in AJAX with rails

I am trying to create a menu for navigation that starts out as

Group1
Group2
Group3
Group4

and when you click on one of the groups it brings up one of the model
tables you can navigate to.

Group1
Group2
|== Model1
|== Model2
|== Model3
Group3
Group4

This is created with two helper methods and the partial _menu.rhtml.
I was wondering how to start to migrate this to ajax. I tried
creating an rjs file but I don t understand the structure and how it
is called in the context of rails.

If anyone could help me I would really appreciate it.

White W.

%= link_to_remote( mg.group_name, :update => “menu”, :url =>
{:controller => “application”, :action
=> “menu”}) unless ms.first.nil? %>

I have gotten a little further, I now have the rjs script
executing . . . but the problem now is that I have many controllers
and I want the action to call the function in application.rb, but it
seems that it can’t find it if it is in the application controller. Is
there a way around this somehow?

<%= link_to_remote( mg.group_name, :update => “menu”, :url => {:action
=> [:menu]}) unless ms.first.nil? %>

other wise this works as I expect it.

Any help is appreciated.
White W.

When I use that syntax I get a routing error
++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++

Processing ApplicationController#index (for 127.0.0.1 at 2007-10-03
12:55:48) [POST]
Session ID: 455c9d0d9f200777765921028a77b9cf
Parameters: {}

ActionController::RoutingError (no route found to match “/application/
menu” with {:method=>:post}):
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/
actionpack-1.13.3/lib/action_controller/routing.rb:1292:in
recognize_path' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/ actionpack-1.13.3/lib/action_controller/routing.rb:1282:inrecognize’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
dispatcher.rb:40:in dispatch' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/lib/mongrel/rails.rb:78:inprocess’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-
mswin32/lib/mongrel/rails.rb:76:in synchronize' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/lib/mongrel/rails.rb:76:inprocess’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-
mswin32/lib/mongrel.rb:618:in process_client' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/lib/mongrel.rb:617:ineach’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-
mswin32/lib/mongrel.rb:617:in process_client' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/lib/mongrel.rb:736:inrun’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-
mswin32/lib/mongrel.rb:736:in initialize' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/lib/mongrel.rb:736:innew’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-
mswin32/lib/mongrel.rb:736:in run' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/lib/mongrel.rb:720:ininitialize’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-
mswin32/lib/mongrel.rb:720:in new' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/lib/mongrel.rb:720:inrun’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-
mswin32/lib/mongrel/configurator.rb:271:in run' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/lib/mongrel/configurator.rb:270:ineach’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-
mswin32/lib/mongrel/configurator.rb:270:in run' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/bin/mongrel_rails:127:inrun’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-
mswin32/lib/mongrel/command.rb:211:in run' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1- mswin32/bin/mongrel_rails:243 E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/ activesupport-1.4.2/lib/active_support/dependencies.rb:488:inload’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/
activesupport-1.4.2/lib/active_support/dependencies.rb:488:in load' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/ activesupport-1.4.2/lib/active_support/dependencies.rb:342:innew_constants_in’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/
activesupport-1.4.2/lib/active_support/dependencies.rb:488:in load' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/ commands/servers/mongrel.rb:60 E:/irail/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:ingem_original_require’
E:/irail/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in require' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/ activesupport-1.4.2/lib/active_support/dependencies.rb:495:inrequire’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/
activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
new_constants_in' E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/ activesupport-1.4.2/lib/active_support/dependencies.rb:495:inrequire’
E:/irail/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
commands/server.rb:39
E:/irail/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in gem_original_require' E:/irail/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:inrequire’
script/server:3
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

To me that looks like its asking for the method to be in application,
like I want, but I already have method defined in application.rb
class ApplicationController < ActionController::Base
layout ‘index’


def menu
logger.info “\n\n\ncalled\n\n\n”
end


end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs