Hit By a Train

|

I'm actually trying to produce something with Ruby on Rails, and I finally got hit by the train. Here's the problem that makes no sense at all. I have a view that does the following:

<%= render :partial => 'role', :collection => @roles %>

@roles is a class attribute that's an array of roles which gets iterated over. This is where things get foobarred. In the partial I get a variable called role which is good, but I want to render a text field in this partial. Rails provides me with text_field. Good again because I can just enter the following to print the role's name:

<%= text_field "role", "name" %>

But wait! text_field will only work with class attributes for some dumb reason. Yes, that means it'll call @role.name to get the name, not role.name. If I wanted @role, I would have used @role in my call to text_field.

I can not figure out why this could have been a good idea. Now I'm stuck contemplating whether I should hack up my own text_field that works logically or not.

Reply

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.
More information about formatting options

Ad's by Google