Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid "Share no more than two instance variables" #179

Closed
ghost opened this issue Apr 23, 2016 · 2 comments
Closed

How to avoid "Share no more than two instance variables" #179

ghost opened this issue Apr 23, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 23, 2016

I agree with this but it makes confusing me.
How to reduce variables or some links if I have a blog app like this?

class PostsController < ApplicationController
  def index
    @posts = Post.all.paginate(params[:page])
    @posts_shown_at_sidebar = Post.first(5)
    @recent_comments = Comment.first(5)
    @pages_shown_at_sidebar = Page.all
  end
end
@panasyuk
Copy link

@nzwsch, try using Presenter and Delegator patterns.
http://nithinbekal.com/posts/rails-presenters/
https://gist.github.com/somebox/5a7ebf56e3236372eec4

@andyw8
Copy link
Contributor

andyw8 commented Apr 25, 2019

Since the this issue's author no longer exists on GitHub, and @panasyuk gave some suggestions, I'm going to close this.

@andyw8 andyw8 closed this as completed Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants