Hi,
when i do this:
<%= method(x) %>
in the view
and the method: is
def method(x)
model.x
end
rails give the error of no argument. how do i assign an argument to
the model?
Hi,
when i do this:
<%= method(x) %>
in the view
and the method: is
def method(x)
model.x
end
rails give the error of no argument. how do i assign an argument to
the model?
On Mon, Sep 1, 2008 at 12:55 PM, tyliong [email protected] wrote:
model.x
end
You can do it like this
model.send(x)
Nevertheless, you normally write
<%=h @model.x %>
in the view, or prepare some @x in the controller that holds model.x,
depending on how important is @model to the view. Do you really need
that level of indirection?
On 1 Sep 2008, at 11:55, tyliong wrote:
def method(x)
model.x
end
First off there’s an internal ruby method called “method” so it’s best
to avoid that. Aside from that your method should be in the
appropriate view helper file.
Having done all that it’s still not going to work:
Fred
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs