Is there a Rails Gem for Page Stats? - ruby-on-rails

I'm allowing users to create sites within my application, and I want to provide simple stats to them like the number of page views. Is there a Rails gem that I can implement to do this?

Check this similar question simple hit counter for page views in rails. Based on the answer to the mentioned question, a gem named impressionist was created by John McAliley. The gem is Rails 3 ready, so you can include it in your app directly.

Try out the StatsMix gem. You can use it to track any action or event in your application. Disclaimer: I'm the founder and it's a subscription based (paid) service. We do have a free developer plan though and have the abilty to embed charts and dashboards to easily allow for providing stats to your users.

Related

How to track admin activities in active admin

I've got Rails 6/Grape API app with active admin on board. Right now I want to have activity logs: monitoring history of changes made by admin such as editing or adding user data. The ideal scenario would be to download this logs in to CSV/XML file.
Is there any gem you can recommend which can cover such an action? Honestly I'd like to avoid writing this from scratch.
Take a look at ActiveAdmin Audit and ActiveAdmin Versioning. You can also integrate PaperTrail yourself.

Admin Panel System Design using Ruby on Rails

I'm trying to make an admin panel for a website that is already running. I've never deployed an admin panel feature, so I want to ask you what the best and most common approach to creating one, and what I need to look out for when I launch it using a subdomain admin.mydomain.com. This website already has users and sessions controller, and I also would like to know how to differentiate two different authentication systems.
Thanks!
you can use Active admin gem.
see the complete documentation from this link https://activeadmin.info/0-installation.html

How to log and utilize usage patterns in a rails app?

I have a rails app and want to log how often a user triggers certain events. I want to use it not just for analytics but to use it as one of the core features in the app (such as ranking and displaying the info).
For example, I could log how often a user comes back to the app and use that information to rank users.
Is there any ruby gem that makes it easier to do something like this?
I didn't think using 3rd party analytics engine was the way to go because this is a core feature to the product. However I am open to suggestions.
Your need is very broad so no matter what you select, you will have to customize it.
I think the merit gem is a good start. You can configure the gem to mark the sessions controller action to gain points and then rank the users using the points.
Some might say that this is not the intended purpose of the gem but I think it depends on what you think the app main purpose.
Check out the gem here: https://github.com/tute/merit
Good luck!

How to handle authorizations based on different subscriptions to users in rails 3?

I am working on Rails 3.2. I am currently building tenant-based site which provides registration to the users. For users those want to register to the site, they need to get subscription plan provided from the site. Based on these subscriptions, I am supposed to provide different authorizations to users. For example, Plan A-subscription will allow user to create some 100 contacts, 100 events and no document uploads, while Plan B-subscription will allow user to create some 250 contacts, 200 events with document uploading features, etc. with further plans.
For this, I require data access authorizations at model level too.
In a nutshell, these functioning specifically lists all authorizations and Access Control lists for the users.
As working on Rails 3.2, I have found few gems which will help to declare authorization-rules for users.
fat_model_auth
declarative_authorization
These gems allow to specify authorization-rules for the application. But I need authorization-rules also at Model level while limiting the access to the database from the user's side. Please suggest me with few documentation or gems to get through...
Any suggestions would be helpful..
I would suggest
CanCan
there is a nice screencast on it aswell.
As the creator of fat_model_auth I can recommend it.
https://github.com/brentgreeff/fat_model_auth
Just released a new gem which works great with Rails 5.

Rails Design Question: How should I structure my controllers for multiple privilege levels?

I am writing a site with multiple levels of privileges. There are basically 3 kinds of users in my system. They are Admin, Business, and Consumers (normal users). Let's just say that I am building an advertising site.
So I have a model "Campaign" which has a RESTful API that comes with rails scaffold. Businesses can create campaigns, users can only see which campaigns they want to join, and admins can do everything.
Now, I know how to apply before_filter and check rigorously for the type of users that can access a particular view.
However, each level of privilege has its own unique views.
Businesses can see the insights and analytics of their campaigns. (let's call this campaigns/analytics)
Consumers can see all the campaigns that they have participated in. (let's call this campaigns/your)
And admins have special views where they can monitor the site's activity. (let's call this campaigns/monitor_businesses).
Right now, my CampaignController has the usual RESTful views + analytics + your + monitor_businesses. Of course, I have multiple data models (not just campaigns) and this makes my RESTful controllers for those data models to be really messy.
What should I do? I am seriously considering starting a ConsumerController and then a BusinessController and put all associated views in these controllers. I don't know if this violates "RESTful" principles but I want to know what better patterns exists to deal with my problem.
I am open to all kinds of suggestions.
Why dont you try the CanCan gem for role management?
You can install as you would any gem using bundler.
It is easy to set up and keeps you from creating the same boilerplate code that you normally would by creating extra controllers or actions.
To get you started I suggest that you visit the documentation on the main page. There is more information about defining what a user can do here and you can see how to check for abilities here.
You also need to add one line to controllers you want to enforce permissions on which you can read about here.
If the standard documentation isnt enough to get you started why don't you take a look at Railscast 192. It shows you how to get up and running with CanCan and it is a great source because Ryan Bates is the creator of the screencast as well as the creator of CanCan. If the video moves too fast for you there is a text version here.
y dont you try the cancan gem for role management http://rubygems.org/gems/cancan
or do gem install cancan I hope this helps.

Resources