Maximilian Schulz schrieb:


Was genau meinst du damit? Du schickst einfach ein leeres Formular?
hallo Maximilian.
Natürlich nicht. Wenn es gefüllt ist, gibt es ja kein Problem, wenn ich es leer lasse, soll die validation greifen


<p><%= simple_format(h @blog.text) %></p>

Gut habe ich geändert, (@blog.blog_text ),scheint aber nicht das Problem zu sein, da der gleiche Fehler auftaucht.


Also an der Stelle wären dann mal die validations interessant. Denn da
scheint irgendwas im argen zu sein.

Nein, das ist wiederum problemlos wenn ich dies weg lasse. <p><%= simple_format(h @blog.text) %></p>
Hier findet er nach erfolgloser validation die Variablen scheinbar nicht...
deshalb:


Noch mal den Code..?
o.k.

<%= link_to 'Kommentieren', { :action => 'new_comment', :id => blog }
im controller:

def new_comment
  @comment = Comment.new
@blog = Blog.find(params[:id]) # Das steht hier damit ich den Eintrag nochmal aufführen möchte und auch wegen der Zuordnungs id
end

def create_comment
  @comment = Comment.new(params[:comment])
  if @comment.save
    flash[:notice] = 'Eintrag wurde gespeichert.'
    redirect_to :controller => 'index'
  else
    render :action => 'new_comment'
  end
end

das sollte klar sein..?

im Template:

  <p><%= simple_format(h @blog.titel) %></p>
   <p><%= simple_format(h @blog.blogtext) %></p>
   <h2>Dein Kommentar</h2>

<% form_tag :action => 'new_comment', :id => @comment do %>
   <%= render :partial => 'comment' %>
   <p><label for="submit">&nbsp;</label><br/>
   <%= submit_tag "Absenden" %></p>
<% end %>

partial:
...
<%= text_area 'comment', 'comment_text'  %></p>
<%= hidden_field 'comment', 'blog_id', :value => @blog.id %>

@Beate

def new_comment
 @comment = Comment.new(params[:comment])
 @blog = Blog.find(params[:id])
 if request.post?
   if @comment.save
     flash[:notice] = 'Eintrag wurde gespeichert.'
     redirect_to :controller => 'index'
   end
 end
end

ergibt folgenden Fehler..
Couldn't find Blog without an ID


irgendwie scheint die Variable id bei der validierung verloren zu gehn..

Gruß Werner








--

Werner Laude
Lindenburger Allee 22  |  50931 Köln

0221.8805 635

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

http://www.webagentur-laude.de

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_______________________________________________
rubyonrails-ug mailing list
[email protected]
http://mailman.headflash.com/mailman/listinfo/rubyonrails-ug

Antwort per Email an