MaD wrote:
> try overriding it like that (i just took the code from github and
> added an if-clause):
>
> def in_place_edit_for(object, attribute, options = {})
> define_method("set_#{object}_#{attribute}") do
> @item = object.to_s.camelize.constantize.find(params[:id])
> # adjust the following if-clause to your needs
> if params[:value].blank?
> params[:value] = "..."
> end
> @item.update_attribute(attribute, params[:value])
> render :text => @item.send(attribute).to_s
> end
> end
Thanks for the response, can you tell me how I'd use the above code?
I've experimented by creating a file called 'extensions.rb' within the
lib folder, the doing: require 'extensions' within environment rb. I've
tried the method on it's own, followed by placing it within a class
wrapper and keep getting errors for 'wrong number of arguments'. My
extensions.rb currently looks like this:
[code]class Extensions
ActionController::Macros::InPlaceEditing::ClassMethods.class_eval do
def in_place_edit_for(object, attribute)
define_method("set_#{object}_#{attribute}") do
@item = object.to_s.camelize.constantize.find(params[:id])
# adjust the following if-clause to your needs
if params[:value].blank?
params[:value] = "..."
end
@item.update_attribute(attribute, params[:value])
render :text => @item.send(attribute).to_s
end
end
end
end[/code]
Thanks for any help
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---