tsturgeon05@comcast.net
2006-Jun-20 19:59 UTC
[Rails] No opening form tag in rendered HTML
I cannot get my form to submit for my simple blog site (based on the "How
to Build a Blog Engine in 15 Minutes" presentation)
Any ideas?
Thanks,
Tom
----------------------------------------------------------------------------
Here is my code:
#Post controller
class PostsController < ApplicationController
def index
list
render :action => ''list''
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def list
@post_pages, @posts = paginate :posts, :per_page => 10
end
def show
@post = Post.find(params[:id])
end
def new
@post = Post.new
end
def create
@post = Post.new(params[:post])
if @post.save
flash[:notice] = ''Post was successfully created.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
def edit
@post = Post.find(params[:id])
end
def update
@post = Post.find(params[:id])
if @post.update_attributes(params[:post])
flash[:notice] = ''Post was successfully updated.''
redirect_to :action => ''show'', :id => @post
else
render :action => ''edit''
end
end
def destroy
Post.find(params[:id]).destroy
redirect_to :action => ''list''
end
#def to control submitting ideatrain
def ideatrain
Post.find(params[:id]).ideatrains.create(params[:ideatrain])
flash[:notice] = "Added your comment."
redirect_to :action => "show", :id => params[:id]
end
end
#show.rhtml
<%= render :partial=>"form", :object => @ideatrain %>
<%= link_to ''Edit'', :action => ''edit'',
:id => @post %> |
<%= link_to ''Back'', :action => ''list''
%>
<h2>Threads</h2>
<% for ideatrain in @post.ideatrains %>
<i><%=ideatrain.thread_subject %></i><br>
<%= ideatrain.thread_body %>
<hr />
<% end %>
<% form_tag :action => "ideatrain", :id => @post %>
<%= text_area "ideatrain", "body" %><br/>
<%= submit_tag "Ideatrain!" %>
</form>
#Partial form
<%= error_messages_for ''post'' %>
<!--[form:post]-->
<p><label
for="post_subject">Subject</label><br/>
<%= text_field ''post'', ''subject''
%></p>
<p><label
for="post_poster">Poster</label><br/>
<%= text_field ''post'', ''poster''
%></p>
<p><label for="post_date">Date</label><br/>
<%= datetime_select ''post'', ''date''
%></p>
<p><label for="post_time_range">Time
range</label><br/>
<%= datetime_select ''post'', ''time_range''
%></p>
<p><label for="post_stage">Stage</label><br/>
<%= text_field ''post'', ''stage''
%></p>
<p><label for="post_votes">Votes</label><br/>
<%= text_field ''post'', ''votes''
%></p>
<!--[eoform:post]-->
