Can you use a Rails Engine with a JS Framework like Vue - ruby-on-rails

I want to do a project with https://github.com/projectblacklight/blacklight
Can I use it as a Rails API with a Vue frontend?
It is a Rails Engine that returns JSON but it is traditionally used in a Rails app as a Plugin / Gem (really it's an engine which is similar).
https://github.com/projectblacklight/blacklight/wiki
Every Blacklight search provides JSON, RSS, and Atom Responses of search results

I am researching this and so far I think the answer is yes.
Jason Coyne from Stanford built an App using Ember with Blacklight
Here are some more discussions around the question.
+ https://github.com/projectblacklight/blacklight/wiki/JSON-API
+ https://github.com/projectblacklight/blacklight/pull/588
+ https://groups.google.com/forum/#!topic/blacklight-development/TIYCjemfp3A
There is not a lot of documentation about this that I can find.

blacklight-vue is an engine made explicitly for this purpose. blacklight-vue-demo is a sample build with this engine. The generic answer for building any Ruby on Rails application with Vue is to use the Webpacker gem.

Related

How to use react ecosystem with rails 3.2?

I just want to share with you an uncomfortable situation that I'm having right now and ask you for advice. It turns out that I'm developing a kind of old project by using rails 3.2 and ruby 2.0. Until now, as usual I've been creating the view layer with haml markup language. Recently I was assigned to implement a new set of UI requirements that seems to be a little complicated. So I was wondering if I could use the react library to do that. I'm using the react-rails gem to facilitate the integration and it works fine. But the problem comes in when I try to use a third party library like react-dropzone or react-modal or whatever react library. I have not been able to get it to work neither using rails-assets gems nor downloading directly the /dist files and require them with sprockets. Some of the errors that I get are:
typeError: undefined is not an object (evaluating 'webpack_require(3).unstable_renderSubtreeIntoContainer')
Can not find module 'react'
I don't know if I can easily setup a webpack server to compile these react libraries and then can be used along with react-rails and the specific version of rails 3.2. I've searched about the subject and I found the webpacker gem but it requires at least rails 4.2. I appreciate any comment or observation about what should I do.
I've finally solved my problem by using react_on_rails gem which allows an easy integration of React + Webpack + Rails, and also includes the server side rendering option.

View component in Rails

Is there any gem available for implementing view components in Rails? I had look at 'cells' and 'apotomo'. I found them good but documentation is not updated for the latest versions. Any one knows about any other good gem for implementing widgets kind of structures in rails?
You can use React js for view level components , use react-rails to integrate it with rails
If you are concerned with performance, you should try solutions like Angular.js , Backbone.js, React.js, Ember.js or any front end MVC framework.
Your code can be organized and run faster than use Apomoto or Rails partials, for example.

What is the best way to integrate angular js app to Rails asset pipeline?

I had an application deployed on two servers : an apache for AngularJS and a Unicorn for Rails 4. Now I want to integrate the Angular app into the Rails one. What is the best way to do this?
In addition to Kevin B's comment, here's a cool tutorial on using Rails (Rails 4) to build a JSON REST API that interacts with an AngularJS frontend. Link: https://thinkster.io/angular-rails/ GL!

Bundle a rails 4 application into a gem?

I am currently developing a rails 4 based media streaming app and wanted to know if i could have the rails app as a kind of source code and bundle it into a gem for distribution? is there some sort of easy solution for this? or do i have to roll my own?
From your description, I think you can do this via an Engine. From the Rails docs:
Engines can be considered miniature applications that provide functionality to their host applications.
...
Engines are also closely related to plugins where the two share a common lib directory structure and are both generated using the rails plugin new generator. The difference being that an engine is considered a "full plugin" by Rails as indicated by the --full option that's passed to the generator command, but this guide will refer to them simply as "engines" throughout. An engine can be a plugin, and a plugin can be an engine.
Read more at http://guides.rubyonrails.org/engines.html

How to use Twitter bootstrap with rails 3.0

How am I supposed to use bootstap with rails 3.0 rather than >= 3.1 ? is there any plugin which supports rails 3.0 ?
I think all of the bootstrap gems require Rails 3.1 or greater. I recently had bootstrap on a 3.0.10 Rails app using the Less.js file that you download from their site: http://lesscss.org/. This is the simplest most basic way to use Twitter-Bootstrap; the file compiles all of your "my_file.less" files into css on the client side.
However, if you want to modify the variables (which is the real power of using this framework) than you need to compile it. You can take a look at this Less compiler: http://wearekiss.com/simpless. I've never tried that, but I hear good things about it and it works on Mac, Linux, or PC.
Probably the easiest thing to do - if you want to compile the code on server side - would be to upgrade your project to Rails 3.1.1 and just use one of the Twitter Bootstrap gems. This is actually exactly what I ended up doing. I was able to update my app to 3.1.1 and I used the Boostrap-Sass gem (just because I slightly prefer Sass).
If you decide to upgrade, follow this RailsCast: http://railscasts.com/episodes/282-upgrading-to-rails-3-1
It helped me a lot.
Ryan Bates also offers a video on how to incorporate Twitter Bootstrap into a Rails app: http://railscasts.com/episodes/328-twitter-bootstrap-basics.
Here's a link to the Sass version of Bootstrap that I am currently using: https://github.com/thomas-mcdonald/bootstrap-sass
Many solutions : you can upgrade to rails 3.1+, might be the better (not the easier, depending on you app) way. You can include the static files yourself if you don't intend to change anything that is handled at the less level. You can do it even if you intend to, but you'll have to recompile the files yourself (or find a way to automate it). Finally, there might be a gem out there that is compatible with rails pre-asset-pipeline, or an old version of a gem. You'll have to look for yourself if you absolutely want a gem.

Resources