Can the delayed_job gem be used outside of Rails? - ruby-on-rails

Is it possible to use the delayed_job gem outside of Rails? Or put another way, can it be used in a pure Ruby project?
If so, how?

I don't know why this person never posted this.
It's easy. Two steps:
http://brkrd.com/post/45269754283/delayed-job-without-rails
UPDATE Looks like the link is broken.
You will need Active Record, but not Rails. You will have to mock a Rails object, and load your database information, environment, and root into the Rails object so that DelayedJob thinks it's in the Rails environment.

Delayed Job looks heavily rails dependent. https://github.com/defunkt/resque resque is a very good gem that is not rails dependent that accomplishes the same goal. You do however have to have redis on your machine which is very lightweight. Resque also has a cool Sinatra web console to see what is going on.

Related

(Ruby on Rails) Which Gem to Automatically Generate A New "Blog Post" Every Day?

I'm making a blog application and want my application to automatically generate a new blog post every day, starting from a user-defined start date. I've heard of a few gems like Clockwork, Whenever, Rufus-Scheduler and I'm not sure which is the best to do this, or if any of them even can.
Has anyone had experience with using any of these gems for something like this? I'm feeling very confused at the moment.
Thanks!
I can't think of any gem as such that will generate/create a post for your user. You have to write your own script for creating posts and the scheduler/or other gems you mentioned above will just help you run that script in the form of rake task at regular intervals of your choice.

Rails Page Specific Maintenance Mode

I have a rails 4.1 application that is in production. There have been one or two instances recently where it would have been beneficial to have one page on maintenance mode while the rest of the site is live. I would like to toggle maintenance page on foobar.com/sign_in by changing the value of an environmental variable or by running a rake task.
I'm open to either using a gem or writing my own tool to handle this. How are other people solving this problem?
You can use turnout gem for this:
https://rubygems.org/gems/turnout

Which route to take for an extension to rails that only needs active record?

So I've been reading tutorials and trying to understand the differences between a ruby gem, a rails engine and a rails plugin however it is not completely clear which path to take.
Say I wanted to make an extension to rails which needs access only to active record within rails.
Should I do this within a rails engine? It seems overkill since I won't be needing routes, controllers, or views just a way to create models which exist within a database. Or do I make a gem that requires rails be installed? and if I do go that route is it possible to have db migrations within the gem. What happens if I just require ActiveRecord? Will others still easily be able to integrate my gem within their own projects?
It would be nice to know that if I do make a gem it is not required that the users absolutely have to have the full rails stack within the application they are working on.

The new elasticsearch-ruby gem integrating with rails

there is any way to integrate the new Elasticsearch gem for ruby to rails, the tire was great but retired since two month and replaced by the new gem, however, no integrating functions with rails yet.
all the tutorial use tire, but now, how we can using rails with Elasticsearch?
A full-featured Rails integration is being worked on. If you want the high-level integration, and you don't want to provide it yourself, you can stick with Tire.
There is another gem called "searchkick" that integrates elasticsearch with Rails:
https://github.com/ankane/searchkick
It has some really cool features and can index data through rake tasks.
I have a minmimal implementation that I'm currently running for prototyping / evaluation of ElasticSearch, which has not thrown up any spanner in the works for a very focused prototyping run for the past 2 days ...
There's little or no error response checking yet, since our workloads heavily use Resque and we rely on Resque to capture and identify where we need to fine tune error handling.
https://gist.github.com/TobiG77/8610788

How to set a minimal Ruby page on a webserver that can add / edit / delete records?

I am trying to add a page on dreamhost.com to display
record = Record.find(params[:id]) # such as Record.find(1)
print record.content # to show content of this record
and that's it... probably using sqlite or mysql, and want to have the ability to add a record, similar to Ruby on Rails's scaffold.
If using Ruby on Rails, it is probably too big for such a simple purpose, but if I use Sinatra, then it looks like I have to start it on a port (and can't start it on port 80 because it is the dreamhost.com's port)
Can Sinatra or any tool or framework fit this purpose?
Go with Rails
Dreamhost offers Rails already installed and at no extra cost. And knowing Rails will certainly be more useful to you in the future than knowing Sinatra.
So, I don't see the benefit in Sinatra unless you are hosting the server.
Since Rails is a framework, it will give you a basic application easily, despite it's massive internal complexity.
I know this doesn't exactly answer the question, sorry about that, but on a shared-hosting site you will have limited opportunity to fiddle with the configuration. It's easier in this case to go with Rails.
Rails isn't really that heavyweight. Unless you need your "app" to be very high performance, Rails is probably a good solution that'll let you have this up in a matter of a couple hours.
That said, I'm sure Dreamhost has a way for you to run a Sinatra app within Phusion.
I wonder why nobody mentioned Padrino yet. It is lightweight and provides you with a simple admin interface!

Resources