I’ve been trying incorporate the in_place_editor, but have had no luck
so far. I read the Ajax.In Place editor wiki on script.aculos.us which
was informing, but still left me wondering about a few things.
Here’s what I’m trying to do. A user has a profile page which lists
their name, age, homepage, etc… There is no form on this page…
it’s just regular text. Here’s a snippet:
At the top of my profile controller I placed the following:
in_place_edit_for :profile, :age
This is where I have a question. How do would I actually go about
saving the new value that was inputted into the text box that popped
up? I have the following in the ‘ajax_update’ action. This obviously
doesn’t work!
I think you will find in_place_editor_field more to your liking here.
Using age as an example, replace BOTH lines above with this:
<%= in_place_editor_field(:profile, :age) %>
Rails will create a static text object that when clicked, becomes a text
box. When the changes are saved, rails uses a dynamic action, you don’t
need to write anything in your controller!
You can also add options for the the button text and such just as you
can with in_place_editor…
<iterate over all object (a) and all languages (l)> <%= a.send
(“name_#{l.short_name}”) %>
<%= in_place_editor(“attribute_#{a.id}_#{l.short_name}”,
:url=>url_for(:action=>‘update_attribute_text’),
:with=>“‘language=#{l.short_name}&id=#{a.id}&value=’ +
escape(value)”) %>
</close iteration loop>
It is code from my current project and it working pretty neat
Also controller code
def update_attribute_text
a = Attribute.find(@params[:id])
a.send(“name_#{@params[:language]}=”, @params[:value])
a.save!
render :text => @params[:value]
end
That’s it. As you see there is no any instance variables.
how can i start or use the in_place_editor of ruby with a given specific
item to input and when i click the the button it should display the
information of the whole item…plz help me
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.