Forum: Ruby on Rails A function that return a link_to, Possible ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-16 18:31
(Received via mailing list)
Hello, I try this :

in application_helper.rb
-----------------------

def lnk bla
    return link_to bla,  { :controller => bli , :action => "blo" , :id
=> "blu" }
end

in file.rhtml
-----------

<%= lnk "yo!" %>

This return an error. There is a way to do this or something similar, or
this is completly impossible ?

Thanks
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2006-01-16 18:34
(Received via mailing list)
On 1/16/06, oo00oo <oo00oo@free.fr> wrote:
> Hello, I try this :
>
> in application_helper.rb
> -----------------------
>
> def lnk bla
>     return link_to bla,  { :controller => bli , :action => "blo" , :id
> => "blu" }

I think you mean :controller => "bli", right?

In the future, it's nice to give the actual error you receive when
stuff doesn't work.

Joe
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-16 18:52
(Received via mailing list)
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
97cbca14d17274370cce501bbea7980a?d=identicon&s=25 Mike Harris (Guest)
on 2006-01-16 19:11
(Received via mailing list)
The link break in the middle of the statement, does that exist in the
actual code.  Does that would definitely cause the error.
Edbd5f1c2f535b14165ae883fa7c3f37?d=identicon&s=25 Jens Alfke (Guest)
on 2006-01-16 19:11
(Received via mailing list)
On 16 Jan '06, at 9:50 AM, oo00oo wrote:

> def lnk bla
>     return link_to bla,  { :controller => "bli" , :action =>
> "blo" , :id
> => "blu" }
> end

If there really is a line break before '=>' in your source code, then
that's a syntax error.

I took your code and pasted it into my app, removing that line break,
and it compiles fine, apart from a warning that you should put parens
around the method arguments. I have similar methods in my own code.

--Jens
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-16 19:20
(Received via mailing list)
Thanks to all :)
This topic is locked and can not be replied to.