|
Revision 7782, 0.6 kB
(checked in by bitsweat, 1 year ago)
|
Fix setter action with non-string fields. References #7418.
|
| Line | |
|---|
| 1 |
module InPlaceEditing |
|---|
| 2 |
def self.included(base) |
|---|
| 3 |
base.extend(ClassMethods) |
|---|
| 4 |
end |
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
module ClassMethods |
|---|
| 17 |
def in_place_edit_for(object, attribute, options = {}) |
|---|
| 18 |
define_method("set_#{object}_#{attribute}") do |
|---|
| 19 |
@item = object.to_s.camelize.constantize.find(params[:id]) |
|---|
| 20 |
@item.update_attribute(attribute, params[:value]) |
|---|
| 21 |
render :text => @item.send(attribute).to_s |
|---|
| 22 |
end |
|---|
| 23 |
end |
|---|
| 24 |
end |
|---|
| 25 |
end |
|---|