How to implement solr search for my rails app? - ruby-on-rails

I have sunspot_rails in my gemfile for my rails app. When I deploy, I use heroku. I find that when I do, I get charged for a heroku add-on that enables this to work. When I remove the add-on, search doesn't work anymore.
Is it possible to use this gem without paying for the add-on or am I doing something incorrectly?

The reason why you need a special Heroku 'add-on' for using sunspot_rails as opposed to many other gems, is because sunspot relies on Solr, which is a actually a separate Java application which needs to be run on your server. Heroku is charging you for running that distinct Solr application. If you weren't on Heroku, you could set up your own Solr instance on your server.

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.

How to configure Solr on few servers?

I'm supporting on rails project, which contain rails app and additional instance with Solr 4.1. Unfortunately, clould provider is not so stable, and oftentimes some server goes on maintenance.
So, I think about how to make 2 identical search servers and some load balancer, instead of one... It will be more stable - if one server will be down, other will continue working.
My environment: rails 3.2.1, ruby 2.1.2, sunspot 2.1.0, Solr 4.1.6.
Is it possible to configure? Please, advise me a right way to do it.
Thanks.

Ruby on Rails hosting with gem "capybara-webkit"

I want to deploy a RoR application that uses a gem capybara-webkit. Is there any free RoR hosting site capable of using that gem?
Heroku is not capable of using it: Is it possible to run capybara-webkit (i.e. forked webkit_server) on Heroku Cedar?
OpenShift is also not capable: https://www.openshift.com/forums/express/error-in-installing-capybara-webkit-gem-while-trying-to-deploy-juvia-rails-app
Is there any other alternative?
I have tired capybara-webkit with digital ocean it works well for me.
for more information http://blog.55minutes.com/2013/09/running-capybara-webkit-specs-with-jenkins-ci/
If you just need to deploy the app on Heroku (and not run tests with capybara-webkit on Heroku), exclude caybara-webkit from the installed dependencies on your Heroku app:
heroku config:add BUNDLE_WITHOUT="development:performance:test"

Can I deploy a Rails App directly onto my companies website?

I have originally been hosting my apps on Heroku, however this is not an acceptable deployment method in my current environment. We have personal information in our applications that deploying to Heroku and setting up DNS forwarding is not acceptable. Regardless of how 'secure' or 'reliable' anyone may think it is, it is just not acceptable in my case.
Our host is siteturn.com, integrated with Plesk 10.4.4. If I SSH onto our websites server as admin and type
ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux].
rails -v
Rails 2.3.5
It appears Ruby and Rails are already installed (Older versions than I require, as I need ruby 1.9.3 and Rails 3.2) If I'm not mistaken it seems like my host 'supports' rails (why else would it already have it installed :P).
How should I go about deploying my application directly onto my companies website?
Heroku is an awesome service but the ease of deploying to Heroku has given you a skewed view of what is involved in hosting your own rails website. Heroku has shielded you from a lot of the hard parts.
For example, just because ruby and rails is installed does not necessarily mean you can host a production rails website. You'll need a rails specific web server (for example nginx and passenger, unicorn, etc). You also need a database (MySQL or Postgres) assuming your web app uses one. Also, as you said you need to upgrade the versions of ruby and rails.
That's just to get the server setup. After that you can get to the deployment part. Capistrano seems to be the most popular choice right now.
Take a look at this railscast episode on deploying to a virtual private server for a very good overview of what is involved. It also briefly goes into Capistrano as well. It's not a free episode but I feel it's definitly worth the money.
Pick up a copy of Agile Web Development with Rails, Third Edition and read what it says about deployment. That should get you started. There's more info required than can be put in a SO answer.

says if i develop a Ruby on Rails application using Rails 2.3.2, will that usually be compatible with Passenger on my hosting company?

says if i develop a Ruby on Rails application using Rails 2.3.2, will that usually be compatible with Passenger on my hosting company?
If i ssh to my hosting company and type rails -v, i get 2.2.2... so looks like they might be using Rails 2.2.2.
So if i develop a Rails app on my Macbook and ftp all files over there, will the Passenger there usually work well with the generated code with the current version of Rails?
Freeze rails into vendor/rails using the built in rake task. That way your app will ue the version of rails you want it to no matter where you deploy it.
rake rails:freeze:gems
And the easiest way to do a specific version I know of.
rake rails:freeze:edge RELEASE=2.3.2.1
Now your version of rails will go with you where you send your app.
You can unpack other gem dependencies into vendor/gems for any gem you are using and want to be sure that it is available where ever you deploy the application.
rake gems:unpack
And to ensure their dependencies go to:
rake gems:unpack:dependencies
I would also suggest that you verify that they are running the latest version of passenger.
I would verify the version of Passenger they have installed (or confirm they have it installed at all). I would also suggest you freeze your version of Rails.
Just second something for railsninja's answer .
First say, it won't work straightaway.
Is that host a vps to you or have sudo access somehow?
If yes, I suggest you to do rake gems:install instead of gems:unpack, because some of gems are os dependent e.g (Rcov, RedCloth...etc.)
I will ask the hosting company of their passenger's configuration, the important question will be if they use RailsSpawnMethod: smart or smart-lv2(default).If they use the smart method, then it is a better idea to freeze your gems and rails otherwise will have the compatible issue as you can find reference from passenger user manual about the RailsSpawnMethod.
It will be nearly 100% compatible if you freeze your gems(all the gems need to be declared correctly in the environment.rb with config.gem, e.g(config.gem 'will_paginate',:source=>"http://gems.github.com")) and RAILS!!!!!

Resources