I'm working on a simple mailer extension (I know the mailer extension,
it doesn't do whatn I need ;-)

When working with the latest 0.6 gems, the controller is not found. I
had to add this to simple_mailer_extension.rb:

 require File.dirname(__FILE__) + '/app/controllers/simple_mailer'

but then I got

/usr/lib/ruby/gems/1.8/gems/radiant-0.6.0/vendor/rails/activesupport/lib/active_support/dependencies.rb:266:in
`load_missing_constant': uninitialized constant ApplicationController
(NameError)

I then went another way and checked out radiant from the svn
repository. In the simple_mailer_extension.rb file, I add this:

   define_routes do |map|
     map.connect '/simple_mailer/:action', :controller => 'simple_mailer'
   end

And I have a simple_mailer controller:
$ cat 
vendor/extensions/simple_mailer/app/controllers/simple_mailer_controller.rb
class SimpleMailerController < ApplicationController
  def index
  end
end

When I try to access http://localhost:3000/simple_mailer/index I get
an error. Here's what I get in the log file:

Processing SiteController#show_page (for 127.0.0.1 at 2007-04-03 09:40:25) [GET]
  Parameters: {"action"=>"show_page", "url"=>["simple_mailer",
"index"], "controller"=>"site"}


NameError (undefined local variable or method `behavior_id' for
#<Page:0xb7642820>):
    .//vendor/rails/activerecord/lib/active_record/base.rb:1792:in
`method_missing'
    .//app/models/page.rb:62:in `behavior'
    /lib/advanced_delegation.rb:10:in `find_by_url'
    .//app/models/page.rb:72:in `find_by_url'
    .//app/controllers/site_controller.rb:29:in `find_page'
    .//app/controllers/site_controller.rb:34:in `show_uncached_page'
    .//app/controllers/site_controller.rb:22:in `show_page'
    .//vendor/rails/actionpack/lib/action_controller/base.rb:941:in
`perform_action_without_filters'
    .//vendor/rails/actionpack/lib/action_controller/filters.rb:368:in
`perform_action_without_benchmark'
    .//vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
    /usr/local/lib/site_ruby/1.8/benchmark.rb:300:in `measure'
    .//vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
    .//vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in
`perform_action'
    .//vendor/rails/actionpack/lib/action_controller/base.rb:408:in
`process_without_filters'
    .//vendor/rails/actionpack/lib/action_controller/filters.rb:377:in
`process_without_session_management_support'
    
.//vendor/rails/actionpack/lib/action_controller/session_management.rb:117:in
`process'
    .//vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch'
    .//vendor/rails/railties/lib/webrick_server.rb:115:in `handle_dispatch'
    .//vendor/rails/railties/lib/webrick_server.rb:81:in `service'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
    .//vendor/rails/railties/lib/webrick_server.rb:67:in `dispatch'
    .//vendor/rails/railties/lib/commands/servers/webrick.rb:59
    .//vendor/rails/activesupport/lib/active_support/dependencies.rb:147:in
`require'
    .//vendor/rails/railties/lib/commands/server.rb:30
    ./script/server:3


Rendering 
./script/../config/../vendor/rails/actionpack/lib/action_controller/templates/rescues/layout.rhtml
(500 Internal Error)

It seems the request is not routed correctly. I took a look at the
ldap extension 
(http://dev.radiantcms.org/radiant/browser/branches/mental/extensions/ldap)
but didn't find any indication of what I'm doing wrong. I guess it
could be a really simple thing I forgot to do.....

Thanks in advance for your help

Raph






On 4/2/07, Sean Cribbs <[EMAIL PROTECTED]> wrote:
> Sounds like you're going down the right path.  What problems were you
> running into?
>
> Sean
>
> On 4/2/07, Raphael Bauduin <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I'm looking to add code to handle a form's action. I wanted to add
> > extension with a controller, but got stuck into problems. What are the
> > steps involved in doing what I want? Is this correct:
> >
> > - generate my extension
> > - edit the extension's class (child of Radiant::Extension) to add a
> > route to my controller. Question: is the controller visible or should
> > I require a certain file, or alter the paths searched for  requires?
> > - write my tests and controller code
> >
> > Thanks in advance
> >
> > Raph
> >
> >
> > --
> > Web database: http://www.myowndb.com
> > Free Software Developers Meeting: http://www.fosdem.org
> > _______________________________________________
> > Radiant mailing list
> > Post:   [email protected]
> > Search: http://radiantcms.org/mailing-list/search/
> > Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
> >
> _______________________________________________
> Radiant mailing list
> Post:   [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>


-- 
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to