---
title: "Comment by Paweł Świątkowski on \"Refactoring instance variables to local variables in Rails controllers\" | Hashnode"
description: "I really like the idea in the post! For some time already I feel that passing data between the controller and the view by setting an instance variable is one of"
url: "https://hashnode.com/posts/refactoring-instance-variables-to-local-variables-in-rails-controllers/63c77761dc79800548ce91b1/comment/63c7baeaedc601710bd097f5"
---

[Discussion](https://hashnode.com/posts/refactoring-instance-variables-to-local-variables-in-rails-controllers/63c77761dc79800548ce91b1)

Comment [Refactoring instance variables to local variables in Rails controllers](https://hashnode.com/posts/refactoring-instance-variables-to-local-variables-in-rails-controllers/63c77761dc79800548ce91b1)

[Paweł Świątkowski](https://hashnode.com/@katafrakt)

[Jan 18, 2023](https://hashnode.com/posts/refactoring-instance-variables-to-local-variables-in-rails-controllers/63c77761dc79800548ce91b1/comment/63c7baeaedc601710bd097f5)

I really like the idea in the post! For some time already I feel that passing data between the controller and the view by setting an instance variable is one of the biggest and most fundamental design flaws of Rails – and I think you provide great examples of how to avoid it.

However, personally I'm not so sure about this keeping the controller action as a one-line render-only thing. Controllers are procedural in nature and I actually like to see what is happening in a step-by-step way. I can understand the allure of hiding the complexity of filtering books in a private method, but honestly I would prefer to at least set the user directly:

```
def index
  user = User.find(params[:user_id])
  books = get_filtered_books
  render locals: { user:, books: }
end
```

I wonder what is your take on that.
