Serving static pages with Rails Metal is actually very simple. Here are the assumptions we’re making.
- Each static page’s content is made up of valid HTML.
- Each static page has a path and content stored in a StaticPage object as defined by the StaticPage model.
- If the path browsed matches the path in a StaticPage object, the content is what is to be delivered.
Here’s the code: Read More
HTML, Rails, Rails Metal, response, Ruby on Rails, tutorial
Have you ever wished you could mix Rack or Sinatra into your Ruby on Rails application just to get its raw throughput on certain parts of your application?
Let’s face it, sometimes, the Rails framework is overkill when we’re returning a simple string or an object in JSON as our response. Your answer for these instances is here. Rails Metal.
Performance
Some people have reported huge speed increases in Rails Metal over the Rails MVC framework. This article claimed a 25x increase over Rails. Pratik Naik from the Rails Core team benchmarked a more believable increase of 4x. Whatever the case, the performance advantage is worth noting.
Read More
activerecord, controllers, erb, HTML, http, middleware, rack, Rails, Rails Metal, response, Ruby, views
When I started writing part II, I started writing about models. As I got a little further along, I realized that it would be more helpful to provide an overview of the controller, which provides the data that goes into your web page, before I showed you how to get the data out of the database. My hope is that you’ll read this thinking of how you want the data provided, which adds context to part III on models.
Controllers are Where the Work Gets Done
Have you ever worked with one of those people who knows exactly where to go to get everything he needs. Can delegate his tasks effortlessly, and then pull it all together in the end. That guy would be our controller. When your website’s user browses to the page, the Rails engine picks up the request and decides which controller to send it to. More specifically, it decides which method in the controller to send it to. The methods on the controller are referred to as actions.
Read More
controllers, Database, erb, HTML, Rails, Ruby, Ruby on Rails, tutorial, views