开发者

Super inplace controls in_place_select displays incorrectly

I'm using the super_inplace_controls plugin to allow users to edit fields on the "show" page. However, I'm running into an issue with the in_place_select function. Here is my view:

<p>
    <b>Status:</b>
    <%= in_place_select :incident, :incident_status, :choices => @statuses.map { |e| [e.name, e.id] } %>
</p>

This is in the 'Incident' view. IncidentStatus is a separate table that has_many Incidents. In the Incident controller, I retrieve @statuses like so:

@statuses = IncidentStatus.find(:all)

Everything works fine for the in_place_select, except the original display. In my browser, it shows:

Status:  #<IncidentStatus:0x1033147d8>

Which means it's not grabbing the current incident_status.name, but it's just changing the object to a 开发者_开发问答string. I'm not sure how to fix this! When I click on the "IncidentStatus:0x1033147d8", everything works properly and I can select the proper fields.

Thanks for any help!


I figured it out. It turns out you can pass in :display_text as an option. So I did the following:

<%= in_place_select :incident, :incident_status, :choices => @statuses.map { |e| [e.name, e.id] }, :display_text => @status.name %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜