# Clilking on a link should replace that link with a form

**URL:** <https://www.ruby-forum.com/t/clilking-on-a-link-should-replace-that-link-with-a-form/160693>\
**Category:** Ruby\
**Created:** [February 18, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/clilking-on-a-link-should-replace-that-link-with-a-form/160693 "2009-02-18T22:40:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@andrew](https://www.ruby-forum.com/u/andrew)\
**Post date:** [February 18, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/clilking-on-a-link-should-replace-that-link-with-a-form/160693/1 "2009-02-18T22:40:32Z")

</div>

Hi everyone!

I’m new to Ruby and JS, and there is a problem I’m trying to solve:  
I need a link that, when clicked, transforms into a form for inputting  
data. I have next code:

(show.html.erb)

 \<%= link\_to\_remote 'New Journal', :url =\> { :action =\> :expand\_create\_form, :controller =\> :journals, :user\_id =\> @user.id } %\>

(expand\_create\_form.js.rjs)  
page[:new\_journal].replace\_html :partial =\> “create”,  
:object =\> @user

The problem is I don’t want to use the controller, is there some  
shortcut to call rjs code when user clicks on “New Journal” link?

---

<div class="post-metadata">

**Author:** ![andrew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@andrew](https://www.ruby-forum.com/u/andrew)\
**Post date:** [February 18, 2009, 10:56pm UTC](https://www.ruby-forum.com/t/clilking-on-a-link-should-replace-that-link-with-a-form/160693/2 "2009-02-18T22:56:28Z")

</div>

Andrew wrote:

> Hi everyone!
> 
> I’m new to Ruby and JS, and there is a problem I’m trying to solve:  
> I need a link that, when clicked, transforms into a form for inputting  
> data.

Ruby doesn’t really have anything to do with links, or with JavaScript.

I think you might want to ask this question on the Rails list.

---

<div class="post-metadata">

**Author:** ![andrew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@andrew](https://www.ruby-forum.com/u/andrew)\
**Post date:** [February 18, 2009, 11:36pm UTC](https://www.ruby-forum.com/t/clilking-on-a-link-should-replace-that-link-with-a-form/160693/3 "2009-02-18T23:36:06Z")

</div>

On Feb 18, 11:55 pm, David M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Andrew wrote:
> 
> > Hi everyone!
> 
> > I’m new to Ruby and JS, and there is a problem I’m trying to solve:  
> > I need a link that, when clicked, transforms into a form for inputting  
> > data.
> 
> Ruby doesn’t really have anything to do with links, or with JavaScript.
> 
> I think you might want to ask this question on the Rails list.

Oh, yes, you’re right.
