A function that return a link_to, Possible?


#1

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


#2

On 1/16/06, oo00oo removed_email_address@domain.invalid 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


#3

Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


#4

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


#5

The link break in the middle of the statement, does that exist in the
actual code. Does that would definitely cause the error.


#6

Thanks to all :slight_smile: