impressionist icon indicating copy to clipboard operation
impressionist copied to clipboard

Adding new column to impressions Table for adding Device

Open Rubioli opened this issue 8 years ago • 0 comments

Am I able to add a new columns to impressions table called device which will either be Mobile or Desktop.

In my application_controller.rb I have this function:

def check_for_mobile
   session[:mobile_override] = params[:mobile] if params[:mobile]
   prepare_for_mobile if mobile_device?
 end
 def prepare_for_mobile
   prepend_view_path Rails.root + 'app' + 'views_mobile'
 end
 def mobile_device?
   if session[:mobile_override]
     session[:mobile_override] == '1'
   else
     (request.user_agent =~ /Mobile|webOS/) || (request.user_agent =~ /iPad/)
   end
 end
 helper_method :mobile_device?

What I want to do is:

    if mobile_device?
      device = 'Mobile'
    else
      device = 'Desktop'
    end

If running condition can't be done from gem since it may not get mobile_device?, how can I do it like how we insert message now: impressionist(@post, "Post", :device => "#{mobile_device?? 'M' : 'D'}")

If I am able to do that, How can I go forward with that and make the gem to add the value to DB.

Thanks in advanced!

Rubioli avatar Feb 06 '17 10:02 Rubioli