obviews

Restores the obvious OOP method interface between Rails controllers and views


License
MIT
Install
gem install obviews -v 0.1.0

Documentation

Obviews

Example

In the controller

class PostsController < ApplicationController
  expose :blog, :posts
  
  def index
  end
  
  def show
    expose post: posts.first
  end
  
  private
  
  def blog
    @blog ||= Blog.first
  end
  
  def posts
    blog.posts
  end
end

In the views:

-# views/posts/index.html.haml
%h1= blog.title
= render posts

-# views/posts/show.html.haml
%h1= blog.title
= render post

-# views/posts/_post.html.haml
.post
  %h2= post.title
  %p= post.body

This project rocks and uses MIT-LICENSE.