The table, software_cis ,contains the following records
id | asset_tag | status | version
----±------------------±--------±--------
1 | AC Logix - AT1 | Status2 | 1.0
2 | RR Logix AT2 | Status3 | 2.3
The table, hardware_cis ,contains the following records
id | asset_tag | status | version
----±------------------±--------±--------
1 | HCL - AT1 | Status1 | 1.0
2 | IBM - AT2 | Status1 | 2.3
The controller, ci_controller, contains the edit method as follows
def edit
@ci=Ci.find(1)
end
My Problem
In the edit.rhtml file, I am trying to populate the value of ‘version’,
an attribute in the software_ci table which is represented by the
content_type, SotwareCi. The sample code is given below.
I am assuming ‘ci.content’ in the above code will represent the model
and ‘version’ will represent the attribute of that model.
When executed the above code didn’t work.
What is wrong here? How I have to proceed?
If we want to simply display the value of ci.content.version, it works
but when tried to edit, it doesn’t work
In the edit.rhtml file, I am trying to populate the value of
‘version’,
an attribute in the software_ci table which is represented by the
content_type, SotwareCi. The sample code is given below.
text_field doesn’t work that way - it expects the first parameter to
be the name of an instance variable
You should look into form_for since it allows you to escape that
convention
In the edit.rhtml file, I am trying to populate the value of
‘version’,
an attribute in the software_ci table which is represented by the
content_type, SotwareCi. The sample code is given below.
text_field doesn’t work that way - it expects the first parameter to
be the name of an instance variable
You should look into form_for since it allows you to escape that
convention
Fred
I created as follows but didn’t work
<% form_for :ci, @ci, :url => { :action => “update” } do |f| %>
CI Name: <%= f.content.text_field :name %>
<% end %>
Fred…will you be able to show me a sample code that tells how a
record is to be edited when there exists a polymorphic relation as
shown
in the starting thread of this talk
The polymorphism is (I think) irrelevant, it’s the fact that there is
an association. There is a good series on railscasts.com about complex
forms.
Fred…will you be able to show me a sample code that tells how a
record is to be edited when there exists a polymorphic relation as
shown
in the starting thread of this talk
The polymorphism is (I think) irrelevant, it’s the fact that there is
an association. There is a good series on railscasts.com about complex
forms.
Fred
But nobody talks/shows the code about editing a record keeping the
concept I introduced in my starting thread…seems to be i am lost
somewhere…can’t proceed…thanks for your support. Really
appreciate your support.
<% form_for :ci, @ci, :url => { :action => “update” } do |f| %>
CI Name: <%= f.content.text_field :name %>
<% end %>
That doesn’t mean anything - you need
form_for :co, @ci.content, … do |f|
f.text_field :name
end
If the form as a whole should apply to ci rather than its content then
you can use fields_for to create the fields (without creating the
tag)
Fred
Fred…will you be able to show me a sample code that tells how a
record is to be edited when there exists a polymorphic relation as shown
in the starting thread of this talk
Thanks
Venu
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.