Hello i"m trying to implement an app which draws its contents via Active Resource, but i'd like to be able to search these contents. is it possible to use sunspot solr with active resource?
Yes. Follow the approach outlined on my blog at http://www.chandranshu.com/sunspot-with-activeresource/ .
The critical part is to create an InstanceAdapter and a DataAccessor and include them into your ActiveResource model. Rest all you can figure out from the errors that you get.
Related
I would like to add the ability to filter records using facets. I know Elastic Search can help with it, but I don't want to setup an elastic search server. I am looking for a really easy solution. I would like to have the search and facets filters run on Postgres and Ruby on Rails 5. Any recommendations?
If you don't want to setup ElasticSearch/Solr server,
FortyFacets appears to be a very good option. It lets you easily build faceted search based on fields of your models (see Active Record model pattern).
Is there a way to make ActiveAdmin show information from a resource that isn't a database?
I have a model that's instantiated from JSON received remotely. I would like to get ActiveAdmin to show this information.
If I seed the database, ActiveAdmin will show the same number of records that I have in the seed file. When I comment out the seed, it shows nothing.
Yes, but you will have to change ActiveAdmin code, and will not be trivial.
Active admin depends on rails which depends on active record.
It also extensively use active record features on the code.
The best path to go is to write a db adapter for Rails using your API. There is one question here that addresses how to create a DB adapter.
I have a site-wide custom written search controller for my Rails 3 app and would like to include results from the site's WordPress blog. What is the best way for me to perform a keyword search on posts from within my Rails app?
If you share database then just use SQL query on it. This solution gives you speed of direct db query but you’ll need to construct that query properly in order to get all relevant data.
If you don't have access to the WP database from your Rails app then the best way will be to use curl, httparty, RestClient or any other file retrieval library.
To do that, create Wordpress page with custom template which will output search results in a format which is best for you to parse in Rails app (json, xml, csv, urlencoded, whatever).
Then request that WP page from your Ruby app using curl/RestClient/httparty…
This solution gives you the power of WP template tags and functions to get the results.
Also instead of creating custom template from scratch you can just simply copy and tweak search.php from core template to provide the results in a format required by your Rails app.
With this solution you are lacking the speed of direct access to db because all search result will have to be transferred through http pipe and you have to process the data twice (encode to the proper format in WP and decode in Rails app).
Interesting problem. I think I would approach it like this:
Use RSS as the text transport from the blog to your rails app. This allows the flexibility to add more blogs in the future, change your blog engine, database host, etc. It also protects you from Wordpress code updates. Given the security history of Wordpress, I like to host them in a protected sandbox anyway. RSS is the native language for blogs, so it seems a natural fit for this kind of content integration.
Use the feedzirra gem to import RSS entries into a rails model.
Use Elasticsearch and tire for fuzzy text searching across both your rails app and your blog entries. See this Railscast for details.
Option 1. is to use search engine for both sites, like elasticsearch, solr etc. So you populate the index from rails and wordpress.
Option 2. You write script, that reads periodically your wordpress RSS and saves data in your rails app.
At the end you should avoid to search from different sources, you should gather the data into one place and then search.
You don't have to stuck with wordpress. You can use Google search APIs. Web search api has been deprecated but still working. Its replacement is Custom Search API. You may need to pay if you query over the limit.
Alternatively you can leverage other search engine APIs like Bing Search API.
I'd suggest using the Wordpress JSON API and plugging that into your search using solr or something similar. You can index as posts are created and then call the articles via the sam JSON interface.
Use Tire and wp-elasticsearch with ElasticSearch.
I'm writing a Ruby on Rails app that would replace an old application. We have an existing Solr service running which I wish to integrate in our new RoR app. What is the best way to approach this? From what I've learned so far online, Sunspot is more suitable for automatically indexing Ruby object in Solr not the other way around (integrating an already existing index) ?!
you can check upon rsolr, on which sunspot is based upon, which will allow you to query on an existing index.
I'm pretty new, but getting the concepts of Ruby on Rails. I'm trying to get a tournament up and running. I added the gem as a dependency in the Gem file; however, I'm unsure where to add my username and API key. This is the API - https://bitbucket.org/corneldm/challonge-api/wiki/Home - And what about displaying the the filtered list in view "Challonge::Tournament.find(:all)." I'm not sure how to connect the preconfigured ActiveResource classes. Has anyone experienced Challonge API for Ruby? Or Another bracket system I could use?
a file in config/initializers would be the conventional place to put that configuration info, probably in challone.rb so its clear what is getting initialized
If you have environment-specific user names and API keys, then you can consider /environments/.rb