Ruby-on-rails – Ruby On Rails Mobile Application

I am trying to develop a Ruby on Rails application that will detect the client, that is, the mobile device (browser) that connects to the server and renders the appropriate layout.
I try to use The following link but still can’t connect to it. Any suggestions?

http://www.arctickiwi.com/blog/mobile-enable-your-ruby-on-rails-site-for-small-screens

I am Use Opera Mini Emulator to test the application.

The most elegant solution I’ve seen is to do Two things: Identify mobile users based on the user agent in the request, and respond with a custom Rails mime type, allowing mobile users to use custom HTML templates.

In config / initializers / mime_types Define a custom “mobile” Rails MIME type in .rb, which is just HTML:

Mime::Type.register_alias "text/html", :mobile

Add help/filter to respond to mobile users:

def mobile_user_agent?
@mobile_user_agent ||= (request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Mobile/.+Safari)/] )
end

Then…

 before_filter :handle_mobile

def handle_mobile
request.format = :mobile if mobile_user_agent?
end

Make a custom mobile template:

app/views/users/show.html.erb => app/views/users/show.mobile.erb

Send mobile or general in the controller:

respond_to do |format|
format.html {} # Regular stu ff
format.mobile {} # other stuff
end

I am trying to develop a Ruby on Rails application which will detect the client, That is, a mobile device (browser) that connects to the server and renders the appropriate layout.
I tried to use the following link but still cannot connect to it. Any suggestions?

http://www.arctickiwi.com/blog/mobile-enable-your-ruby-on-rails-site-for-small-screens

I am Use Opera Mini Emulator to test the application.

The most elegant solution I have seen is to do two things: identify user agent-based Mobile users and respond with custom Rails mime types, allowing mobile users to use custom HTML templates.

Define a custom “mobile” Rails in config/initializers/mime_types.rb MIME type, it’s just HTML:

Mime::Type.register_alias "text/html", :mobile

Add help/filter to respond to mobile User:

def mobile_user_agent?
@mobile_user_agent ||= (request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Mobile /.+Safari)/] )
end

Then…

before_filter :handle_mobile

def handle_mobile
request.format = :mobile if mobile_user_agent?
end

Make a custom mobile template:

app/views/ users/show.html.erb => app/views/users/show.mobile.erb

Send mobile or regular in the controller:

 respond_to do |format|
format.html {} # Regular stuff
format.mobile {} # other stuff
end

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3308 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.