Implement capistrano in ruby on rails having database MongoDB - ruby-on-rails

I want to implement capistrano in my ruby on rails project. I am using MongoDB as database .
I install capistrano gem.
capify .
[add] writing './Capfile'
[add] writing './config/deploy.rb'
[done] capified!
It gives me file deploy.rb inside the Config. What should i do inside. so where do i have to put mongoid.yml ? Working code is helpful for me to do or some hints is appreciable.

You should first be clear about why you want to implement capistrano :-)
Capistrano is a tool for making deployments easier - it allows for executing commands in multiple remote machines, via ssh.
For a default installation of a Rails App with mongodb, you don't need to have anything related to mongodb in the capistrano deploy.rb file.
You would add some mongodb stuff in this file if there is some mongodb related task that you want to accomplish every time the code is deployed to the remote servers.
Example: Here is a capistrano recipe example to synchronize local mongodb with production
I would recommend that you familiarize yourself with the basics of capistrano by watching the railscast episode on capistrano tasks.

Put mongoid.yml in /config, and type cap deploy in /.

Related

Wy use the Rails envs?

Hello i'm starting to deploy my rails application in Digital Ocean host, before that i was developing locally and using webrick in Development mode, now that i'm deploy i'm using Unicorn in Production Env.
So if i change something on my sourcecode both envs will be affected. So why the exist? which the correct way to use it?
thanks
Rails environments allow developers to maintain common elements (code, certain gems) and custom elements (other gems, environment settings, etc) for development, test and production.
For instance, you may want to use a simple DB like SQLite for development and just capture any emails generated in your log, but in production you want to use Postgres and (obviously) you need to send emails to users. The Rails environment structure makes it very easy to maintain these separate configurations without duplication.
In your example, you want to use Unicorn in production as your application server. This is easily accomplished by adding the Unicorn gem in a production group in your Gemfile like so:
group :production do
gem 'unicorn', '4.8.3'
end
Of course you will also need a Unicorn configuration file but hopefully this helps you appreciate the power and utility of Rails environments.
I would recommend taking some time to read the documentation here.

Where can I find reliable documentation for creating Capistrano tasks?

I'm at a loss trying to find reliable documentation for creating Capistrano tasks on an application that I'm trying to upgrade. I've tried to find documentation on
Capistrano Docs
Hungry and Foolish Writing Capistrano tasks
Rails Cast Capistrano Task
and some wikis that are generally unhelpful or provide snippets of capistrano tasks. I know that Capistrano version 3 is based off Rake file syntax but what I want to do is to find a list of keywords/commands so I can rewrite pre-written Capistrano tasks from an earlier version. Links or resources would be much appreciated. Thanks.
*I am working on an application that has been using Capistrano 1.6 and now I need to upgrade to 3. The tasks are written, all I need to do is translate it into Cap 3.

Rails EC2 Deployment - no such file to load

I'm working against a variety of constraints that are troubling an EC2 Rails deployment. I'm not allowed to use Capistrano because I cannot save this application to any public git repository (like GitHub) and I also need to retain complete control over which instance on EC2 the Rails application is installed to and be able to modify this easily (adding load balancers, auto-scalers, etc.) on the fly from the AWS Console, so I also cannot use Rubber.
I finally resorted to simply ssh'ing my Rails application directory over to the EC2 instance, but am running into a 'no such file to load' error when running bundle install, specifically the Time gem. Because this is an 'integrated' gem, I think I might just be overlooking something simple. Here are the things that I've tried:
I've used RVM to manage my versions of ruby, rails, rubygems, etc.
Deleting my Gemfile.lock file and re-running bundle-install
Including 'Time' in my GemFile and re-running bundle-install
This application runs without issue on my local development environment, so what am I overlooking?
Note: I am REQUIRED to host on a single EC2 instance. Otherwise, I'd simply deploy to EBS, Heroku, etc.
This was a stupid mistake, also detailed in this question: heroku - cant run rake db:migrate - no such file --Time
I incorrectly had a require statement in a controller for 'Time', instead of 'time'. This was allowed locally, but my ubuntu server ruby environment was not as forgiving. Changing the 'T' to a 't' in my controller and running 'bundle install' resolved this issue completely.

How to install ror on apache

Is all I need mod_rails and ruby 1.9.2? What is the best resource for production setup of rails.
The first time I deployed a Rails app, I simply read this.
Once this config done, I recommend you learn how to use capistrano.

De-capistrano a rails app?

I've inherited a rails site that I need to deploy (quickly!) to our webhost, which is a standard *nix shared server that uses FastCGI for rails apps. I've worked with rails sites on multiple occasions in the past but wouldn't consider myself an expert by any stretch.
This particular app was developed using capistrano, with which I've got no experience, and everything I've read leads me to believe that to deploy the app "properly" would require my setting up an external svn account, among other things, which aren't feasible given our time frame and hosting situation.
My question is: what is the best way to quickly get this application up and running without using capistrano? I received, along with the site files, a .sql dump that I've already imported, and I've configured config/database.yml to reflect the correct production db settings. Right now, running ruby script/console production yields the following error message:
/home/user1/ruby/gems/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:443:in `load_missing_constant':NameError: uninitialized constant ApplicationController
Thanks for your consideration!
As the others already stated, you are probably using the incorrect version.
Rails switched from app_controller to application_controller (or something like that) in version 2.1 or 2.2.
There is a rake task that you should be able to run in that case:
rake rails:update:application_controller
It might help you.
As for the capistrano. In your deploy.rb you can add the parameter :deploy_via :
set :deploy_via, :copy
set :scm, :none
And it should use the copy you are having in your working directory to deploy with (no need for subversion or any other version control)
Copy usually fetches the code from a repository locally and then uploads it to the server, but also setting the :scm to none it should ignore that and just (hopefully) use your working copy instead.
All capistrano requires is a deploy.rb and a Capfile, this is not what is causing your error. From the looks of it it seems that the problem is that you're using a gem rails version which is incompatible with your app, do you know which version it was developed with? If so you should try vendoring your rails directory to the right version.
For deployment, if you're using FastCGI you can just upload the files to the host and set the appropriate permissions and you should be good to go. Going forward you might want to look at upgrading to a newer version of rails, using capistrano and changing your environment to use apache passenger.
I hope this helps.
The problem you're running into appears to be a mismatch of your installed version and the version that the app is expecting. Look in config/environment.rb, Toward the top you'll see something that looks like:
RAILS_GEM_VERSION = '2.3.4'
You need to make sure that the version of rails installed on your machine matches whatever version is declared in that file. You can do that by running:
sudo gem install -v=X.X.X rails
where X.X.X matches what was in your environment.rb.
Jonnii is suggesting you "freeze" your rails by including all the rails code into your project directly, (which can be done by running rake rails:freeze:gems AFTER you have followed the above steps and gotten the correct gems installed in the first place.) Once you've frozen rails, then you no longer need to have the rails gems installed on your webserver machine.
Good luck!

Resources