My main problem is Im not able to intialize the project object. Im
explaining in detail
In my view/project/myprojects.rhtml
<%= link_to ‘Edit’
,{:action=>‘newcomment’,:controller=>‘project’,:id=>project}%>
Using this file for the user to enter a new comment
view/project/newcomment.rhtml view
<%= render :partial => ‘users/user_tabs’ %>
<%= error_messages_for :project %>
<% form_for(:project, :url => {:controller => “project”, :action =>
“editcomment” },
:html => { :multipart => true, :name => “ref_form”
}) do |f| -%>
|
|
<TR>
<TD HEIGHT=25>Reference Comment</TD>
<TD HEIGHT=25 align="left"><%= text_area "comment", :cols
=> 20, :rows => 5 %>
href=“javascript:document.dyna_form.submit()”;> -->
<%= image_submit_tag("/images/create.jpg")%>
|
|
|
<% end %>
controllers/project_controller.rb
def newcomment
@project=Project.find(params[:id])
end
def editcomment
@project.comments.build(params[:comment])
end
Now Im failing to pass the initialized @project object inside
editcomment method
-Saurav
Im passing the project id parameter using
Ryan B. wrote:
Oh I should re-enforce the fact that build does not create a comment
object,
it merely initializes a new one. You will still have to save it. That
is,
unless you change build to create, in which case it’ll just create it.