Skip to content

elia/obviews

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Restores the obvious OOP method interface between Rails controllers and views

Resources

License

Stars

Watchers

Forks

Packages

No packages published