Hi…
I’m trying to edit a field in a table named software_cis. The name of
the controller is ci_controller and the action is give_functional_spec.
In give_functional_spec.rhtml file I wrote the code for interface. Then
in the ci_controller, I wrote:
def give_functional_spec
@software_ci.functional_spec= params[:ci] @software_ci.save
end
But this generated an error message: "The error occurred while
evaluating nil.functional_spec= "
Hi…
I’m trying to edit a field in a table named software_cis. The name of
the controller is ci_controller and the action is give_functional_spec.
In give_functional_spec.rhtml file I wrote the code for interface. Then
in the ci_controller, I wrote:
def give_functional_spec
@software_ci.functional_spec= params[:ci] @software_ci.save
end
But this generated an error message: "The error occurred while
evaluating nil.functional_spec= "
Can anyone help to fix this issue please.
Regards
Now i made a modification in ci_controller:
def give_functional_spec
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci] @software_ci.save
end
— !map:HashWithIndifferentAccess functional_spec: along with the data
entered is saved to the table.
Now i made a modification in ci_controller:
def give_functional_spec
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci] @software_ci.save
end
— !map:HashWithIndifferentAccess functional_spec: along with the data
entered is saved to the table.
How can i solve this?
It will be helpful if you give the data type of the functional_spec.
Also the view file code for the ci form.
Now i made a modification in ci_controller:
def give_functional_spec
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci] @software_ci.save
end
Try giving like this…
def give_functional_spec
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci][:functional_spec] # Changed @software_ci.save
end
Now i made a modification in ci_controller:
def give_functional_spec
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci] @software_ci.save
end
— !map:HashWithIndifferentAccess functional_spec: along with the data
entered is saved to the table.
How can i solve this?
It will be helpful if you give the data type of the functional_spec.
Also the view file code for the ci form.
Now i made a modification in ci_controller:
def give_functional_spec
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci] @software_ci.save
end
Try giving like this…
def give_functional_spec
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci][:functional_spec] # Changed @software_ci.save
end
Karthik
I tried that also. But an occurred:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
Now i made a modification in ci_controller:
def give_functional_spec
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci] @software_ci.save
end
Try giving like this…
def give_functional_spec
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci][:functional_spec] # Changed @software_ci.save
end
Karthik
The problem while doing this is that while executing this method, it
tries to retrieve the data in params[:ci][:functional_spec]. But there
is no data in the hash, because the method in the controller is executed
first and only after that the view is executing.
The problem while doing this is that while executing this method, it
tries to retrieve the data in params[:ci][:functional_spec]. But there
is no data in the hash, because the method in the controller is executed
first and only after that the view is executing.
Correct. I think, you will have to change the approach.
So, for the first time when you render ‘give_functional_spec.rhtml’, try
to render without calling the method.
In controller where you call the ‘give_functional_spec’ method,
The problem while doing this is that while executing this method, it
tries to retrieve the data in params[:ci][:functional_spec]. But there
is no data in the hash, because the method in the controller is executed
first and only after that the view is executing.
Correct. I think, you will have to change the approach.
So, for the first time when you render ‘give_functional_spec.rhtml’, try
to render without calling the method.
In controller where you call the ‘give_functional_spec’ method,
render :action => ‘give_functional_spec’
Try this.
I tried this:
def give_functional_spec
render :action => ‘give_functional_spec’
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci] @software_ci.save
end
Still its not working…
I tried this:
def give_functional_spec
render :action => ‘give_functional_spec’
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci] @software_ci.save
end
Still its not working…
if you are opening the give_functional_spec.rhtml’ page by directly
giving the URL in the browser, then what i said will not be applicable.
How do you render the ‘give_functional_spec.rhtml’?
Are you redirecting from any method or directly giving the url in the
browser like,
I tried this:
def give_functional_spec
render :action => ‘give_functional_spec’
@software_ci= SoftwareCi.find(params[:id])
@software_ci.functional_spec= params[:ci] @software_ci.save
end
Still its not working…
if you are opening the give_functional_spec.rhtml’ page by directly
giving the URL in the browser, then what i said will not be applicable.
How do you render the ‘give_functional_spec.rhtml’?
Are you redirecting from any method or directly giving the url in the
browser like,
in the above statement, you have used ‘params’ in the view file. I dont
think we can use params in a view. It is just for passing the parameters
from view to controller. Check it and try.
in the above statement, you have used ‘params’ in the view file. I dont
think we can use params in a view. It is just for passing the parameters
from view to controller. Check it and try.
It works… Thank you so much.
Actually i did the same method for creating, editing and searching. I
was finding whether there is any alternate method for this. This method
requires 2 rhtml files and 2 methods in the controller. So it may become
more complex in the future if more capabilities have to be implemented.
Thanks…
It works… Thank you so much.
Actually i did the same method for creating, editing and searching. I
was finding whether there is any alternate method for this. This method
requires 2 rhtml files and 2 methods in the controller. So it may become
more complex in the future if more capabilities have to be implemented.
Thanks…
If you are using the same view code in many places, explore on the
examples of partial view files and start using it.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.