Forum: Ruby on Rails WML sites

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
59bea58f406ca9f19f7820c79d61bfc9?d=identicon&s=25 Biji (Guest)
on 2006-03-10 14:00
Hi all

how to make a WML view for rails pages?
I've tried to create like:
<wml>
<card>
CONTENT
</card>
</wml>

but my phone says unsupported content type...


thanks
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kasper Weibel (Guest)
on 2006-03-10 14:20
(Received via mailing list)
Do something like this in your controller

def configure_charsets
      super
      @response.headers["Content-Type"] = "text/vnd.wap.wml;
charset=utf-8"
end

I have used the xml builder templates to make wap output. Start with two
lines like this.

xml.<<"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
xml.declare! :DOCTYPE, :wml, :PUBLIC, "-//WAPFORUM//DTD WML 1.3//EN",
"http://www.wapforum.org/DTD/wml13.dtd"

look here too
http://wiki.rubyonrails.com/rails/pages/
HowToProvideAlternateViewsForMobileDevices
1e90246fc67e699c32e59db89d4ff5c3?d=identicon&s=25 Michael Kaiser (Guest)
on 2006-03-10 14:20
(Received via mailing list)
Hi Biji,

I couldn't try this, but this should help you anyways:
You have to serve the document with the correct content type header for
wml, which should be "text/vnd.wap.wml", so in your controller you
should have a

@headers["Content-Type"] = "text/vnd.wap.wml"

HTH,
Michael


Biji schrieb:
Ed677538fabc317e91830ccd4901b7ee?d=identicon&s=25 Tobias Schwab (tobstarr)
on 2006-06-09 13:58
Hi!

I think the best thing is to use an after_filter like this:

class ApplicationController < ActionController::Base
    after_filter :set_content_type

    def set_content_type
        @headers["Content-Type"] ||= "text/vnd.wap.wml"
    end
end

Either you enable the filter in your ApplicationController (to enable
the wap header for the complete application) or only in specific
controllers. You can put the method set_content_type in your
ApplicationController and just enable the filter in each controller with
after_filter :set_content_type.

Using an after_filter and ||= allows you to set the header in some
actions manually. Only if that header is not set the filter sets the wap
header.

Bye,

TobStarr
This topic is locked and can not be replied to.