I’m getting more bizzaro behavior with my extension now relating to
loading.
In this case, a routing declaration is working the first time, and then
failing on the second try.
My partial calls:
url_for(:controller => ‘page_attributes’, :action => :add)
the first time it loads, and things look ok. (after a fresh server
restart)
But then when I go to another page and come back I get a:
No route matches {:controller=>“admin/page_attributes”, :action=>“add”}
I’m defining my route by doing:
define_routes do |map|
map.connect ‘admin/page_attributes/:action’, :controller =>
‘admin/page_attributes’
end
at the top of my extension (like the other ones do)
Can somebody please explain something about the magic that loads
extensions.
Apparently something is working when the extension is first loaded and
then fails when it is re-accessed.
thanks,
Jacob
I’m getting more bizzaro behavior with my extension now relating to
loading.
my stacktrace
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1252:in
generate' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in
rewrite_path’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in
rewrite' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in
url_for’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in
url_for' /Users/igotimac/radiant_svn/mental/radiant/vendor/extensions/page_attributes/app/views/admin/page/_attributes.rhtml:116:in
_run_rhtml_47vendor47extensions47page_attributes47app47views47admin47page47_attributes46rhtml’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in
compile_and_render_template' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in
render_template’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in
render_file' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:275:in
render’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/partials.rb:59:in
render_partial' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in
benchmark’
/usr/local/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/local/lib/ruby/1.8/benchmark.rb:307:in
realtime’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in
benchmark' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/partials.rb:58:in
render_partial’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:287:in
render' #{RAILS_ROOT}/app/views/admin/page/edit.rhtml:125:in
_run_rhtml_47app47views47admin47page47edit46rhtml’
Anybody know what the deal with the weird 47s is?
Jacob,
I am looking at the routes issue. The 47’s are part of the template
compilation magic. You can ignore it.
adam williams
I have just checked in some additional tests that show extension
routes working fine. I also created an extension, put in a custom
route, generated a link using url_for, and have no problems. A couple
of comments below:
thanks Adam
I think things may be messed up in my case because I’m trying to add
functionality to the page edit screen.
I did this by directly editing page/edit.rhtml (in core radiant) and
adding:
<%= render :partial => ‘attributes’ %>
But that partial exists only in my extension.
This works, but I get the exception the second time _attributes.rhtml is
loaded (via a page edit).
I was thinking this would just be a temporary hack to make sure things
work, and then later I would figure out how to enable the registering of
a tab with the Page Edit interface just like you can register a new tab
for the overall admin interface.
So, so far I’m stuck here, but maybe I’m taking the wrong approach to
modify the page edit screen. Any other suggestions?
thanks,
Jacob
Jacob,
I have just checked in some additional tests that show extension
routes working fine. I also created an extension, put in a custom
route, generated a link using url_for, and have no problems. A couple
of comments below:
On Feb 3, 2007, at 9:36 PM, Jacob B. wrote:
My partial calls:
url_for(:controller => ‘page_attributes’, :action => :add)
Should that be :controller => ‘admin/page_attributes’?
the first time it loads, and things look ok. (after a fresh server
restart)
Production or development?
‘admin/page_attributes’
end
at the top of my extension (like the other ones do)
Can somebody please explain something about the magic that loads
extensions.
Apparently something is working when the extension is first loaded and
then fails when it is re-accessed.
We are simply listening to Dependencies.clear, at which point we
reload the extension classes explicitly, and have hooked into route
reloading - which happens around the same time - so that we can get
the extensions routes back in play.
aiwilliams
Jacob,
You can redefine any view template in your extension without modifying
the core. So if you wanted to override the page edit interface, just
copy and modify app/views/admin/page/edit.rhtml to
vendor/extensions/my_extension/app/views/admin/page/edit.rhtml. That
way you can keep your modifications separate from the core
functionality.
Sean