ruby on rails - undefined method `request_uri' ActionDispatch -


i want create mobile version of website

i want when visit site mobile device redirect him subdomain m.mywebsite.com

but there choice go full site stored in cookies

here config

app/controllers/application_controller.rb:

class applicationcontroller < actioncontroller::base   # prevent csrf attacks raising exception.   # apis, may want use :null_session instead.   protect_from_forgery with: :exception    before_filter :set_mobile_preferences   before_filter :redirect_to_mobile_if_applicable   before_filter :prepend_view_path_if_mobile    private      def not_authenticated       flash[:warning] = 'you have authenticate access page.'       redirect_to login_path     end      def expirated_reset_token       redirect_to root_path     end    # mobile subdomain      def set_mobile_preferences         if params[:mobile_site]           cookies.delete(:prefer_full_site)         elsif params[:full_site]           cookies.permanent[:prefer_full_site] = 1           redirect_to_full_site if mobile_request?         end     end      def prepend_view_path_if_mobile         if mobile_request?           prepend_view_path rails.root + 'app' + 'mobile_views'         end     end      def redirect_to_full_site         redirect_to request.protocol + request.host_with_port.gsub(/^m\./, '') +                     request.request_uri , return     end      def redirect_to_mobile_if_applicable         unless mobile_request? || cookies[:prefer_full_site] || !mobile_browser?           redirect_to request.protocol + "m." + request.host_with_port.gsub(/^www\./, '') +                       request.request_uri , return         end     end      def mobile_request?         request.subdomains.first == 'm'     end      helper_method :mobile_request?      def mobile_browser?         request.env["http_user_agent"] && request.env["http_user_agent"][/(iphone|ipod|ipad|android)/]       end     helper_method :mobile_browser?  end 

the problem when visit

http://m.mywebsite.com/?full_site=1 

it give me

undefined method `request_uri' #<actiondispatch::request:0x007fdb60fa8a00> did mean? request_parameters 

please help

actiondispatch request not, indeed, implement or respond method request_uri.

it has many other methods, though. 1 of them surely return want (whatever is). here's link documentation perusal: actiondispatch::request.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -