Kaleb Walton wrote:
> I'm quite unfamiliar with Mental and only recently started working
> with Radiant - I'll look into Mental to see if it meets my needs.
> Thanks!
Hi I'm fighting this too on Mental.
My problem is that included pages (via r:find) have no access to the
request.
This is because in app/models/page.rb Page stores the request into
instance
variables, but the find tag will construct a new page - and since nobody
will call
process(request, response) on that, it will have these instance
variables left on nil.
I tried to fix this in an extension, I "reopened" the Page class and
clobbered the request= and request definitions with a new implementation
wich stores into a class level variable.
This is almost ok, except that the process() call is not very nice, and
accesses
the @request directly and not via the attr_writer function, so I had to
clobber
that too.
This works if I edit page.rb directly, but when I try to "reopen" the
class,
and rewrite a few functions mysterious failures pop up - like no layout
being
rendered, broken admin pages... etc.
Please someone smarter than me: What is wrong with this:
in vendor/extensions/example/app/models/page.rb
require "app/models/page"
class Page < ActiveRecord::Base
@@request = nil
def request= rq
@@request = rq
end
def request
@@request
end
def process(request, response)
self.request = request
self.response = response
if layout
content_type = layout.content_type.to_s.strip
@response.headers['Content-Type'] = content_type unless
content_type.empty?
end
headers.each { |k,v| @response.headers[k] = v }
@response.body = render
self.request = nil
self.response = nil
end
end
I do require this file from the example_extension.rb so it does run
My guess is that some magic must be happening inside Page with the
subclasses
which prevent me from successfully patch it from an extension.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant