# Use link to post

**URL:** <https://www.ruby-forum.com/t/use-link-to-post/126071>\
**Category:** Rails\
**Created:** [January 15, 2008, 6:50am UTC](https://www.ruby-forum.com/t/use-link-to-post/126071 "2008-01-15T06:50:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 15, 2008, 6:50am UTC](https://www.ruby-forum.com/t/use-link-to-post/126071/1 "2008-01-15T06:50:31Z")

</div>

Hi,  
I know I have been a little “long winded” but I really need to use link  
to do a post/submit. It is in one of the requirements of the project I  
am doing now.

I have tried using \<%= link\_to\_function ‘Next’,  
“$(‘update\_product’).submit()” -%\>. It works though. But I can’t have  
two of this link\_to\_functions and redirect each link to a different  
page. And I had got a feed back saying this link\_to\_function is a  
complicated way of doing link. So I tried using \<%= link\_to ‘PREVIOUS’,  
{:controller =\> ‘create\_user’,  
:action =\> “save\_user” , :method =\> :post} %\>

But this doesn’t work as it does not post the values I keyed into the  
various fields. Instead, it posts an ampty form. I really hope someone  
can help me with is problem.

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 15, 2008, 7:44am UTC](https://www.ruby-forum.com/t/use-link-to-post/126071/2 "2008-01-15T07:44:08Z")

</div>

Ryan B. wrote:

> The project is not following the conventions of Rails. There are helpers  
> (ala submit\_tag) already in place to make this easier in you. Is this a  
> work  
> project or a school project?
> 
> The reason why: %= link\_to ‘PREVIOUS’,  
> {:controller =\> ‘create\_user’,  
> :action =\> “save\_user” , :method =\> :post} is not  
> working is because you’re not passing in the parameters. It’s kind of  
> like  
> trying to go to [http://google.com](http://google.com) and expecting it to have already  
> looked up  
> what you wanted to search for.
> 
> On Jan 15, 2008 4:20 PM, user splash [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > complicated way of doing link. So I tried using \<%= link\_to ‘PREVIOUS’,
> > 
> > >

Hi,

Its kink of a school project. So how do I pass the parameters in ?

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 15, 2008, 7:34am UTC](https://www.ruby-forum.com/t/use-link-to-post/126071/3 "2008-01-15T07:34:56Z")

</div>

The project is not following the conventions of Rails. There are helpers  
(ala submit\_tag) already in place to make this easier in you. Is this a  
work  
project or a school project?

The reason why: %= link\_to ‘PREVIOUS’,  
{:controller =\> ‘create\_user’,  
:action =\> “save\_user” , :method =\> :post} is not  
working is because you’re not passing in the parameters. It’s kind of  
like  
trying to go to [http://google.com](http://google.com) and expecting it to have already  
looked up  
what you wanted to search for.

On Jan 15, 2008 4:20 PM, user splash [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> complicated way of doing link. So I tried using \<%= link\_to ‘PREVIOUS’,
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 15, 2008, 10:40am UTC](https://www.ruby-forum.com/t/use-link-to-post/126071/4 "2008-01-15T10:40:57Z")

</div>

user splash wrote:

> Hi,
> 
> Its kink of a school project. So how do I pass the parameters in ?

Hi,  
This is what I did to try to oass the parameters:

\<%= link\_to ‘PREVIOUS’, {:controller =\> ‘create\_user’,  
:action =\> “save\_user”, :user =\> {:username=\> ‘username’,  
:password=\> ‘password’, :age =\> ‘age’}, :method =\> :post} %\>

I don’t know if this is the right way to pass parameters but I got  
values 0 for each fields that was being entered into my database.Did I  
do it correctly?

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 15, 2008, 2:53pm UTC](https://www.ruby-forum.com/t/use-link-to-post/126071/5 "2008-01-15T14:53:10Z")

</div>

You could set a javascript function on the onClick event of the link  
which would do a .click on a button with style=“visibility:hidden;” I  
guess… but It’s not really an elegant solution.

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 15, 2008, 8:51pm UTC](https://www.ruby-forum.com/t/use-link-to-post/126071/6 "2008-01-15T20:51:44Z")

</div>

:url =\> {  
:controller =\> create\_user,  
:action =\> ‘save\_user’,  
},  
:with =\> “‘address=’+encodeURIComponent($F('text\_field\_name))”,  
:method =\> :post

from here  
[http://ariejan.net/2007/02/21/ror-link\_to\_remote-with-a-text\_field-value-as-an-argument/](http://ariejan.net/2007/02/21/ror-link_to_remote-with-a-text_field-value-as-an-argument/)

On Jan 15, 1:53 pm, Emanuele R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 15, 2008, 12:54pm UTC](https://www.ruby-forum.com/t/use-link-to-post/126071/7 "2008-01-15T12:54:56Z")

</div>

No. Just use a submit\_tag, it is MUCH easier. I cannot help you further.

On Jan 15, 2008 8:10 PM, user splash [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.
