Open ColinTheRobot opened 10 years ago
Thanks for all of the info.
The fix is basically chanigng https://github.com/upmin/upmin-admin-ruby/blob/master/lib/upmin/attribute.rb#L13 to call model.model.send
(instead of model.send
) for any attribute name equal to the instance methods in Upmin::Model
https://github.com/upmin/upmin-admin-ruby/blob/master/lib/upmin/model.rb
The full (current) list would be:
Until this change gets committed, I would add the following in your app to app/views/upmin/partials/attributes/_topic_title.html.haml
:
- title_value = attribute.model.model.title
- is_nil = model.new_record? ? false : title_value.nil?
.form-group{class: attribute.errors? ? "has-error" : ""}
%label{for: attribute.form_id}
= attribute.label_name
- if attribute.editable? && f = form_builder
.input-group
= f.text_field(attribute.name, value: title_value, class: "form-control")
.input-group-addon.nilable-addon
.form-group
%label{for: "#{attribute.form_id}_is_nil"}
Make this Nil
= check_box(model.underscore_name, "#{attribute.name}_is_nil", class: "boolean", checked: is_nil, value: is_nil)
- else
%p.well
= title_value
This won't fix the search results, but it will fix the the form view temporarily.
Just FYI - I haven't tested the code above, so if it doesn't work first try let me know and I'll help you debug it, but that should be correct.
That's great thanks! It totally works.
Is there an edge branch that has the model.model.send fix in it?
The Issue
Form in model view as well as in the initial view of all objects related to a specific model, pulls the wrong value for a single attribute for one specific model.
It only appears to happen with this one specific field name (
t.string "title"
).Versions and gemfile
Upmin 0.1.0 Rails 4.1.4 Ruby 2.0.0p451
model attributes and sample object
The model in question has the following attributes:
From the outset, the
Topics
view does not show the correct title, "Function-based needs-based projection", but showsTitle Topic # 2
Similarly, after clicking the Topic object,
Title
in the formform#edit_topic_2
continues to read asTopic # 2
as doesmodel.title
called in the<h3>
tag at the top.I did notice that specifying
model.model.title
displays the correct title.Further functionality I explored was a custom admin action for topics to update the title.
_app/upmin/models/admintopics.rb
This action does render correctly on the page, and performs the action as expected—updating the Topic Title attribute. However, while the change is reflected in the database, it is not reflected in the model view.