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 -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Suneeta Km wrote:> 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. > > RegardsNow 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? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karthi kn wrote:>> 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.The data type of functional_spec is text. The code of give_functional_spec.rhtml is: <%= render :partial=>''cipart/ci_header'' %> <%= start_form_tag ({:action => ''give_functional_spec'', :method => ''post''}, :class => ''itilform'')%> <table cellpadding="4" cellspacing="0" border="0" width="100%" class="itiltable2"> <tr> <th colspan="4" class="alternative"> <label for="ci_comments" >Functional Specification</label> </th> </tr> <tr> <td width="25%" colspan="4"><%= text_area "ci", "functional_spec", "cols" => 80, "rows" => 5 %></td> </tr> </table> <table> <tr> <td> <%=submit_tag(''Save'') %> </td> </tr> </table> <%= end_form_tag %> -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
>>> 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 -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karthi kn wrote:> >>>> 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 > > > - KarthikI 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.[] -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Suneeta Km wrote:> Karthi kn wrote: >> >>>>> 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. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > 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. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karthi kn wrote:> >> >> 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... -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > 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, http://localhost:3000/cis/give_functional_spec ??? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karthi kn wrote:> >> >> 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, > > http://localhost:3000/cis/give_functional_spec > > ???Yes, i''m redirecting from another method: <%= link_to ''Give Functional Specification'', :controller => ''ci'', :action => ''give_functional_spec'', :id => @software_ci.id, :ci_number => params[:ci_number] %> -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Yes, i''m redirecting from another method: > <%= link_to ''Give Functional Specification'', :controller => ''ci'', > :action => ''give_functional_spec'', :id => @software_ci.id, :ci_number => > params[:ci_number] %>According to me, in this case, it will be better if you use another method like ''save_functional_spec'' to save the functional_spec. Keep the save operation statements in ''save_functional_spec'' method. Use the ''give_functional_spec'' method for finding and rendering the functional_spec. That may work. Also, <%= link_to ''Give Functional Specification'', :controller => ''ci'', :action => ''give_functional_spec'', :id => @software_ci.id, :ci_number => params[:ci_number] %> 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. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karthi kn wrote:> >> Yes, i''m redirecting from another method: >> <%= link_to ''Give Functional Specification'', :controller => ''ci'', >> :action => ''give_functional_spec'', :id => @software_ci.id, :ci_number => >> params[:ci_number] %> > > According to me, in this case, it will be better if you use another > method like ''save_functional_spec'' to save the functional_spec. > > Keep the save operation statements in ''save_functional_spec'' method. > > Use the ''give_functional_spec'' method for finding and rendering the > functional_spec. That may work. > > Also, > > <%= link_to ''Give Functional Specification'', :controller => ''ci'', > :action => ''give_functional_spec'', :id => @software_ci.id, :ci_number => > params[:ci_number] %> > > 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... -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > 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. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---