Hi,

I'm creating a new format for an iPhone/iPod connections.

My problem is that iPhones/iPods always receive the .html pages.

If I comment the format.html # index.html.erb then the devices receive
the .xml format, and If I coment this one they receive the format.iphone
wich is the expected.

In the .html pages I add some code to test if the device is really an
iPhone or not:

<% if iphone_user_agent? # Show message for iPhone users -%>
<div class="message">
    <p>Using an iPhone? <a href="http://iphone.foo.com/";>Use the
optimised version</a>.</p>
</div>
<%else%>
<p>Welcome iPhone user!</p>
<% end -%>

And when the device is an iPhone/iPod I get the Using an iPhone? message
...

Of course I'm connecting from an iPhone/iPod or through the iPhone
simulator from Xcode.

When I use a simple browser from a computer I expect the .html versions,
wich I'm receiving as default no matter wich device/browser is
connected.

What did I miss ?

thanks,

r.



In config/initializers/mime_types.rb

# Be sure to restart your server when you modify this file.

# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
 Mime::Type.register_alias "text/html", :iphone



class ScannsController < ApplicationController

  around_filter :login_required


  def index

    @scanns = Scann.find_by_sql("SELECT * FROM totals_diaris_avui")
    @page_title="Scanns of today"

      respond_to do |format|
        format.iphone  # action.iphone.erb
      format.html # index.html.erb
      format.xml  { render :xml => @scanns }
      end

  end

...

end
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to