I am developing a Rails application which can add some beautiful text on the image. So I used the powerful tool ImageMagick(wrapped by gem MiniMagick).
As I said I need to make the text looks beautiful, so I have to install some fonts on both my Mac OS X and Ubuntu Server which can be used for ImageMagick. For example, this beautiful Lato fonts.
on Ubuntu Server
Actually, on Ubuntu, there is already a package to intall. It’s very straightforward.
Because the script generated the name is not as same as it is on Ubuntu Server. So we can manually edit the ~/.magick/type.xml file and change the name, then in the code we use the same font name.
接下来我们再来看看IntegrationTest这个类,它首先通过引入Integration::Runner模块,从而一起引入了ActionDispatch::Assertions模块,然后Runner中运行测试的时候,会创建Integration::Session类的实例,Integration::Session引入了Integration::RequestHelpers模块,所以我们就可以使用像get, post, put等HTTP请求相关的方法。
具体的这些请求相关的方法,参考文档: ActionDispatch::Integration::RequestHelpers
require'test_helper'classBaseController<ApplicationControllerdefindexhead:okendendclassBaseControllerTest<ActionDispatch::IntegrationTestincludeDevise::Test::IntegrationHelperssetupdoRails.application.routes.drawdoget'base'=>'base#index'endendteardowndoRails.application.reload_routes!endtest'redirects if user is not logedin'doget'/base'assert_response:redirectassert_redirected_to'http://www.example.com/'endtest'returns success if user is loggedin'dosign_inusers(:one)get'/base'assert_response:successendend
As a practical rails developer, we all want to keep up to date with new Rails direction and status. With coming Rails5 we will have Turbolinks 5 and Rails API.
Turbolinks 5 focuses on integration with native iOS and Android Wrappers. Rails API is designed for the client-side MVC and 100% native mobile apps.
Turbolinks acturally is very good technology. It gives rails developers the performance benefits of SPA approaches without writing a lot of javascript.
What we need to do is just follow Rails guide and keep all of you JS and CSS in the HTML <head>. Turbolinks will only load the body party via AJAX when user triggers a link.
But sometimes if I want to update part of the page with Rails, I can response a piece of javascript rendered with a html partial, this is also very cool.
And PJAX is another good solution,especially when your page has a side menu bar or tabs, PJAX can update the content part of the page.
Some of the famous rails websites are using turbolinks, like Shopify, Github(pjax) and Basecamp.
So if you haven’t used it, you can start with the Turbolinks 5.