简体   繁体   中英

Why does some ruby rails gem work on some server and not on others?

I'm new to ruby on rails development but I am a little confused with why different gems work on some servers and not on others.

Intro: I started learning rails on http://ruby.railstutorial.org/ . I also started watching some railscasts by Ryan Bates on http://railscasts.com/

On railscasts, Ryan was talking about using sunspot for text searching. Then, someone in the comment says that using sunspot for production server is tedious. If it works locally on your machine, shouldn't it work on production server?

On railstutorial, mike was talking about search as well but he mentions Thinking Sphinx and he said to use it for shared host or dedicated server. For heroku, use their docs on text search.

This is my first web development project and came from Windows background so backend servers are still very unknown to me. Is it because of the different types of server (Ex: Nginx, Apache...)?

Thanks much!

Many of those gems require you to set another service up or they may be memory or resource intensive. It really depends on what type of hosting you are going with and the specific gem, if you are on shared hosting for Rails getting things to work can be hard since you don't have full control over the system.

Yko,

My guess is that the comment related to sunspot being difficult to use in production is because in production, you'd probably want to setup your own instance of Solr rather than use the embedded instance of Solr that ships with sunspot. They were probably referring to setting up Solr, not using the gem specifically.

The sunspot gem lets you easily interact with the Solr full-text search engine from within Rails, sort of like other gems that allow you to integrate with Redis, MySQL, MongoDB, etc. To make this easier in development, sunspot includes an instance of Solr as part of the gem. This makes is easy to do a simple " gem install sunspot_rails ", then run rake tasks to start/stop Solr. No need to setup Solr separately on your local machine.

That's great for development, when you're getting things working on your local machine. But in production, you may want to have a separate instance of Solr running.

Continuing with the database analogy, imagine if the MongoMapper or MySQL gems came with an embedded instance of their respective database. That would be okay in development - one less thing to setup on your system. But not so great in production, where you may want to tweak certain settings on your database, setup failover, etc.

Same thing here with Solr.

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM