# Can you pass data when you render :action

**URL:** <https://www.ruby-forum.com/t/can-you-pass-data-when-you-render-action/100086>\
**Category:** Rails\
**Created:** [July 27, 2006, 1:44am UTC](https://www.ruby-forum.com/t/can-you-pass-data-when-you-render-action/100086 "2006-07-27T01:44:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![blewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@blewis](https://www.ruby-forum.com/u/blewis)\
**Post date:** [July 27, 2006, 1:44am UTC](https://www.ruby-forum.com/t/can-you-pass-data-when-you-render-action/100086/1 "2006-07-27T01:44:58Z")

</div>

how can i do:  
render :action =\> “headline”, :id =\> @user.id

Thanks,  
Ben L.

---

<div class="post-metadata">

**Author:** ![blewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@blewis](https://www.ruby-forum.com/u/blewis)\
**Post date:** [July 27, 2006, 6:03am UTC](https://www.ruby-forum.com/t/can-you-pass-data-when-you-render-action/100086/2 "2006-07-27T06:03:42Z")

</div>

sorry, that’s user\_id, not :user\_id (in the partial)

---

<div class="post-metadata">

**Author:** ![blewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@blewis](https://www.ruby-forum.com/u/blewis)\
**Post date:** [July 27, 2006, 7:38am UTC](https://www.ruby-forum.com/t/can-you-pass-data-when-you-render-action/100086/3 "2006-07-27T07:38:44Z")

</div>

render :action =\> “headline”, :locals =\> {:user\_id =\>  
@user.id}[http://user.id/](http://user.id/)

and then it will be accessible via :user\_id in the partial

> **[ActionController::Base](https://api.rubyonrails.org/classes/ActionController/Base.html#M000206)**
>
> Action Controllers are the core of a web request in Rails. They are made up of one or more actions that are executed on request and then either it renders a template or redirects to another action.

ed

---

<div class="post-metadata">

**Author:** ![blewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@blewis](https://www.ruby-forum.com/u/blewis)\
**Post date:** [July 27, 2006, 10:27am UTC](https://www.ruby-forum.com/t/can-you-pass-data-when-you-render-action/100086/4 "2006-07-27T10:27:06Z")

</div>

render :action =\> ‘headline’ does not actually run the headline  
method. You need to run it explicitly:

def other\_action  
@user = User.find(params[:id])  
headline  
render :action =\> ‘headline’  
end

def headline

# you can access @user in here

end

AFAIK … but I haven’t done this in a while so things may have  
changed.

-Jonathan.
