Ruby on Rails with Github Pages - ruby-on-rails

I am attempting to host a project using Github pages. As I understand it, Ruby on Rails cannot be run on GH-Pages, with the exception of using Jekyll. My project is not a blog, and therefor Jekyll seems like overkill. Is there any other way to deploy to GH-Pages? Is there another way to generate a static site from my Ruby on Rails app that would allow for easier deployment?
Thanks for any and all input.

I'm afraid not. Rails is a dynamic system, meaning that the pages are generated from templates combined with data. GH-pages only servers static HTML, so even if you put static content into Rails, you would not be able to run the scripts that serve it.
Use Jekyll or Middleman to make a static site. If you really need Rails, use Heroku's free plan.

You could use actionpack-page_caching to generate page-level caches in the public folder of your Rails application, then add those generated pages to your GitHub Pages repository.
However, this entirely defeats the purpose of using something like Rails. Why don't you just create static pages directly and upload those to your GitHub Pages repo?

Related

What is the easiest way to integrate static pages into Rails project

I have a landing page that was passed to me by a designer, the Structure is like this
|_startup
|_common-files
|_css
|_fonts
|_icons
|_img
|_js
|_less
|_flat-ui
|_bootstrap
|_css
|_fonts
|_js
|_fonts
|_icons
|_img
|_js
|_less
|_ui-kit
|_static
|_css
|_less
index.html
I didn't type the whole structure, but the idea is, it's quite a bit of directory, and it might be tough to separate it into javascript, css, image assets, and fonts(I am not sure where fonts go). My thoughts are, should I just have a subdomain and put this about page? I do want to integrate the page into my rails project. My question is, is there an easy way to integrate an independent page into my rails project?
From the book Learn Ruby on Rails:
A Rails application can deliver static web pages just like an ordinary
web server. The pages are delivered fast and no Ruby code is required.
The Rails application server looks for any pages in the public folder
by default.
So you can drop the directory into your application public/ folder.

Compile Rails application to static site

I want to know if there is a way (or a gem) that can compile me a Rails application into a static web site; I have some files that need to only be compiled once (i.e. they have no dynamic content but they need to be parsed at least once). I can't seem to find any way to do that so I have a feeling that it might not even be possible.
I don't believe there's a way to do that with an entire Rails app. That's more the territory of https://github.com/mojombo/jekyll or https://github.com/imathis/octopress. If it's only a few pages you can use caches_page :page1, :page2, ... in your controllers. That will write the fully-rendered page to public/ so that it can be served directly by Nginx/Apache on subsequent requests.
Edit In Rails 4 you'll need to use the actionpack-page_caching gem.

Locomotive CMS with Rails - location for liquid templates

I'm new to both Ruby on Rails and Locomotive CMS, but I'm just starting to create my first site with them.
I've got the engine running in a full Rails app (I'm going to need to deploy it on our own server later on). But it's just spitting out the 'Template' content defined through the admin interface, without any other template/content around it.
I can 'fix' it by shoving the html for the whole page in through this input field. But that's not right, surely? The Getting Started guide talks of putting the templates in the filesystem, at something like: Pages/index/first page. "All pages are inherited from index". I have an index.liquid under views/pages but it's not picking that up... (I've tried a couple of other locations too).
I'm sure this is a dumb question, but please could someone tell me where to put my template in the file system? Or how to point Locomotive to pick it up from the right place?
(I did get the file system liquid template working by defining it through the Rails way, with a route, a controller and adding a liquid template initializer I found here. But then it's missing the variables that should come from the CMS content).
I'm loading the site using bundle exec unicorn_rails. And I'm using Rails v3.2.13, Ruby v1.9.3 and Locomotive_cms v2.2.2.
Thanks!
I'm Didier from LocomotiveCMS.
LocomotiveCMS is a little bit different from the other CMS, in a sense, we offer a tool named Wagon to manage your site locally without having to install mongodb, rails and some other components.
Another huge benefit is that you can write your templates in HAML and your CSS in SASS/ SCSS or Less (we embedded Compass as well) and with our preferred texts editor (editing a whole site in a browser is a nightmare).
That's a nice eco-system in order to be super efficient when it comes to develop a LocomotiveCMS site.
Once you're done with your local work, you can deploy your site to a remote LocomotiveCMS engine in a similar way you push your application to Heroku. Actually, pushing a site will create the back-office for the final end user.
I suggest you to read that page.
http://doc.locomotivecms.com/guides/get-started/requirements
and this one too
http://www.locomotivecms.com/tour
Our message is still not clear on our official website but believe me, we are working to make it better.
Hope it will help you !
Didier

Using WordPress + Jekyll for the static pages in a Rails project

I have a website that has product pages(dynamic) and corporate pages(fairly static). Both are coded in Rails. This means the marketing team has to involve the dev team to make any changes to the static pages. To address this issue, I am thinking about migrating the static pages to a CMS.
I am considering following approaches:
WordPress + Jekyll
Marketing team maintains the static pages at a private Wordpress site (eg: foo.wordpress.com).
When the marketing team is ready to deploy the change, a command line tool converts the WP pages to static pages using Jekyll and commits the changes to a git repository.
The changes to the git repository are uploaded to the Amazon S3 bucket associated with the raills application asset.
Marketing team is already familiar with WP and it is quite easy to find a good WP theming resource.
Rails based CMS : Locomotive/Radiant
The CMS resides within the rails app.
Has anybody done this type of deployment. In your opinion which approach is better of the two and why?
I prefer having the CMS integrated in with the Rails app. This way you only have one layout and set of stylesheets to maintain.
Finding a Rails based CMS that makes it easy to integrate into your own application and works the way you want it to might be a bit more challenging. Most of the ones I've seen, the CMS is the application and you have to use its hooks to customize things.
With that said, it isn't that hard to build a simple CMS to use within your own application. Wordpress uses tinymce as the wysiwyg, which isn't that hard to get working in a Rails app. Also, take a look at Refinery, as it may fit your needs just fine.

Can a Rails app and a Jekyll blog live together?

I have a Rails app and I want to add a blog feature; my idea is to use Jekyll which is a great blog tool, I just need to figure out if it's possible to use http://my.app.com/blog as a url (knowing that Jekyll will run its own server process with its own url).
Does anybody know of a way to accomplish this? It'd be great to be able to do so. Best regards!
... just need to figure out if it's possible to use http://my.app.com/blog
as a url (knowing that Jekyll will run its own server process with its own url).
While jekyll's web server works, it will be probably easier, simpler and safer to use your rails app's webserver for serving all pages.
The simplest way of doing what you want is hooking a jekyll invocation to your server's git repository, so jekyll's static content is added automatically to your rails app's public/blog/ directory every time there is a push.
Create a symbolink link called public/blog inside your app's public folder. Make it point to the generated _site folder of your jekyll repository.
On the git repository that controls the contents of the jekyll blog, add a post-receive hook that does the following:
#!/bin/sh
rm -rf _site
jekyll
Those are the basic steps. You might have to configure the read permissions properly, ignore the /blog/ link if you are using an SCM (like you should) and automate the link creation if you are using Capistrano or Vlad for deploying.
There are other alternatives, like using a real folder instead of a symbolic link and having jekyll generate stuff directly there, but I feel the one I'm presenting is the cleanest.
Would you be using nginx to reverse-proxy the Rails app? If so, you should be able to just carve out an exception so /blog is served directly by nginx instead of forwarded to Rails.
Check out this gem: https://github.com/zbruhnke/bloggy
And this blog post about it: https://blog.engineyard.com/2012/introducing-bloggy-a-simple-way-to-add-a-jekyll-blog-to-any-rails-application
I had the same problem a few weeks ago. If you really have to use Jekyll, I think the best solution is to use the already mentioned Bloggy gem.
However, I wasn't satisfied with this solution, because you still have to duplicate or synchronize a lot of things like templates, routes, stylesheets, and so on. So I decided to implement my own simple Jekyll-like blog functionality in Rails.
You can find my article describing the implementation here: Create a simple Jekyll-like blog in your Rails 4 app.

Resources