active job in rails 4 - ruby-on-rails-4

I am looking forward to active job for active record for rails 4. I search related to it. I found gem 'delayed_job_active_record' . But this supports Rails 3+.
In that I want to run the job everyday at some specific time to check the due date. If due date reached, before some particular period Want to send alert message/mail. And I am using devise for authentication.
And also I see the gem 'devise-async-activejob'. Is this affect my authentication system? Which gem can I use for this scenario without affecting my existing features. Suggest any Guide or documentation or sample.
Thanks.

Set the queue_adapter in config/application.rb
config.active_job.queue_adapter = :delayed_job
See the rails guide for more details.
See
http://edgeguides.rubyonrails.org/active_job_basics.html
https://blog.codeship.com/how-to-use-rails-active-job/

Related

Running rails app both as engine and app

I'm transforming a Rails application (say appA) into engine so that I can hook it into another Rails app (say appB). However appA must run as a Rails app solely as well. That's because a customer can buy
appA or
appB with appA. There is no option of buying only appB.
Following rails oficial guide I made (among others) following changes:
Changed Rails.application.routes.draw to ActionPlan::Engine.routes.draw in routes.rb.
Created lib/action_plan/engine.rb with content shown below:
module ActionPlan
class Engine < ::Rails::Engine
isolate_namespace ActionPlan
end
end
Now when I run rails s I get /action_plan/config/routes.rb:1:in '<top (required)>': uninitialized constant ActionPlan::Engine (NameError).
I guess I should initialize ActionPlan::Engine in application.rb file somehow but I don't know how neither whether it's the way to go.
So is it possible to build an app/engine in rails such as appA? If it is, how can I overcome that problem?
After some researching and talking to some friends, I found out that it's not possible to do such a think with rails, but it's possible you to create another rails app (say appC) and use it only to run your engine, i.e appC is a silly rails app used only to make it possible to run your engine.

File browser with Django and Alfresco

I have a Django site and a local install of Alfresco (community edition). One of my model contains a file reference which maps to a document in Alfresco. The view should have a field that spawns a file browser that can access the repository structure within Alfresco so that the user can pick whichever file they want at whichever version.
I looked at the CMSIlib module and it seems to be providing all the interaction I need for the back end code. Although downloading a document seems clunky.
There are lots of Django file browsers but none seem to interface with CMSIlib.
Do I have to code my own or have I missed something?
The version is Alfresco Community v5.0.0 (d r99759-b2) schema 8022 Spring Surf and Spring WebScripts - v5.0.0.
To be honest, I am not a python guy ! But I heard over the official #alfresco IRC channel that cmislib is not so much of an active project, and questions about it only bump once in a while .... The RESTful api however may be considered as a good alternative in your use case:
To access alfresco content using the RESTful api, you should be querying this webscript: /alfresco/d/<d|a>/<workspace>/<store>/<nodeId>/<filename>
where :
d and a refer to direct / attached mode
<workspace>, <store> and <nodeId> reference your content nodeRef
<filename> a file name of your choice
So you should be making a GET Request an a URL that looks something like this http://<host>:<port>/alfresco/d/d/workspace/SpacesStore/8444ad61-4734-40e3-b2d4-b8b1c81347fd/myFile.ext
Note : Depending on the permission set on your node, you might need to attach an alf_ticket to the URL for an authenticated alfresco user. Please check this for further insights.
UPDATE 1:
If you have a problem identifying your file nodeRef, then you can setup a repo webscript implementing your custom logic (browsing some folder / searching for a document by name or metadata ....)
If your are not familiar with webscript development check Jeff Pott's tutorial on the subject
UPDATE 2:
To get started with your webscript development check out Alfresco docs/wiki!
Check this wiki page to learn how to retrieve children for a given node !
Or check this wiki page to learn how to develop webscripts implementing your custom business logic.
If you do not have anything against the YUI javascript library (that is no longer actively maintained), you can integrate the object-finder already available in Alfresco Share. The library is in
share/components/object-finder/object-finder.js
You will need to modify it a bit given that you are not inside Share.
To be totally honest, I do not know if it is feasible because it has other dependencies but being a browser site library, in theory can be integrated everywhere.

Ruby gem or snippet to use different ActiveRecord db connection depending on model attribute value

Can you suggest a ruby gem or show a snippet with exsmple how to make AtiveRecord::Base successor to choose a db connection depending on a model record id?
Ok. Please let me know if the following solution can work if not then I will delete it from here.
I wouldn't use Gem for this.
Here a mud map how I would tackle this project. ( for small to medium projects only )
Ruby Class: manages all the connections.
Query handler: dictates what connection do we need based on the
condition.
Connector is a simple class that grabs stuff from
Rails and trigger the query handlers.
Query handler is the optional bit. You can connect your Rails directly to the Ruby Class. ( I don't like this as they will be coupled a bit too much )
Have your database.yaml file (just to keep Rails happy) Your application will be using the Ruby Class connector and query handler to grab stuff from different databases, No Rails needed there.
Hope this help!
PS: Again if you think this is not good solution let me know and I see what I can do. Cheers mate.

No data in Sitecore Experience profile

I've set up a local Sitecore environment with all sql and mongodb db's working.
Except i do not get any data in the experience profile (contacts)
I see that tracking_contact db is empty in mongo and also the analytics index folder is empty.
Other functionalities like experience analytics work fine.
Are there any extra configurations necessary?
The Experience Profile runs on the Analytics index. If there is no index, there will be no data shown.
Try to rebuild the index if it's not there.
There is an admin tool for rebuilding the reporting db & analytics index: /sitecore/admin/RebuildReportingDB.aspx
When you run the tool you must setup a secondary reporting db first.
Just attach another empty analtyics database to your local SQL and name it something like analytics_secondary and configure its connectionstring.
Then rebuild the reporting db and after that data should appear in your Experience Profile.
The index should be constantly refreshed by the aggregation framework (i.e. you should not need to rebuild) so if that is not happening, something is wrong in your configuration.
When working with xDB you'll need to identify a user to get it to appear in the experience profile section otherwise they will be anonymous.
Try using this code here to create a contact:
https://github.com/ianjohngraham/CoreBlimey.Utils/tree/master/CoreBlimey.Utils/xDB%20Contact%20Creator
And then call the end session by using the button.
If everything is setup correctly then the contact you created will appear in MongoDB and in Experience Profile.
If you are still not getting any data then you could try these things:
Ensure you have the <sc:VisitorIdentification runat="server" /> control for asp web forms layout
the #Html.Sitecore().VisitorIdentification() control for MVC layout
Make sure you disable robot detection by changing this setting <setting name="Analytics.AutoDetectBots" />
Charley,
I also had the similar problem in past, so what I found was, it was not working in my local, but when i put it stage server it shows data to me. So same may apply to you also.
Also without "#Html.Sitecore().VisitorIdentification()" in your Layout tracking is not possible.
Hope this will help you.
cheers!!

Rails 4 undo "rails destroy MODEL"

I was installing Devise into my Rails 4 application and misread the line in the wiki that talks about generating devise as a new model. I thought I needed to add it to each of my existing models. I used "rails g devise messages" to install devise in my messages model then realized that I was doing it wrong. So I used rails g devise messages to remove devise. This command got rid of my messages model entirely (the model that the whole app is built around). I have looked all over for how to reverse this but can't seem to find anything. I tried running rake db:rollback but it only rolled back my previous installs.
PLEASE tell me that there's some way to retrieve the model, views, controller and 300+ entries!
Thanks for the help!