A function that return a link_to, Possible?

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

On 1/16/06, oo00oo [email protected] 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


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

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

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

Thanks to all :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs