[Rails] Ajax Update: error: undefined method `model_name'
Rails 3.1.3
I am not sure Rails can do what I want to do.
I have a form for update like,
<%= form_for script, :remote => true do |f| %>
<%= f.hidden_field :video_id %>
<%= f.text_field :startp, :readonly => true %>
<%= f.text_field :text %>
<%= f.submit "update" %>
<% end %>
then, JavaScript (jQuery) inserts a value for 'startp' and for 'text' in
to the 'text_field' .
Of course, this set of values is already stored in DB. I want to update
it after editing it.
This form gives an error
undefined method `model_name' for NilClass:Class
whose I assume the cause is the nil object 'Script'. The object is not
properly passed.
I try to render this form like following.
<%= render :partial => "update_script",:locals => { :script =>
Script.find_by_startp(params[:startp])} %>
Since 'startp' is readonly and users should be able to edit only 'text',
I hoped to associate the 'text' with 'startp' rather than 'id' of
'script'.
Is there anyway to pass the obejct?
It is very difficult to explain the situation. But if someone can guess
the problem and have some suggestion, I would appreciate it.
Thanks .
soichi
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home