On Dec 14, 10:58 pm, David Kahn <[email protected]> wrote:
> Did you look at your ArticlesController for clues?
Um...yes. But I didn't see anything odd.
> Also, does your app function through the browser but not running the tests?
Yes, running rails server works fine. It's the tests that give this
error.
> Would not hurt to copy your ArticlesController here, and maybe also your
> Environment.rb
Okay. I'm in Rails 3, though, so environment.rb is probably useless
to look at...
Here's the articles controller:
class ArticlesController < ApplicationController
# GET /articles
# GET /articles.xml
def index
@articles = Article.all(:limit => 6)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @articles }
end
end
# GET /articles/1
# GET /articles/1.xml
def show
@article = Article.find(params[:id])
@section = @article.section
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @article }
end
end
# GET /articles/new
# GET /articles/new.xml
def new
@article = Article.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @article }
end
end
# GET /articles/1/edit
def edit
@article = Article.find(params[:id])
end
# POST /articles
# POST /articles.xml
def create
@article = Article.new(params[:article])
respond_to do |format|
if @article.save
flash[:notice] = 'Article was successfully created.'
format.html { redirect_to(@article) }
format.xml { render :xml => @article, :status
=> :created, :location => @article }
else
format.html { render :action => "new" }
format.xml { render :xml => @article.errors, :status
=> :unprocessable_entity }
end
end
end
# PUT /articles/1
# PUT /articles/1.xml
def update
@article = Article.find(params[:id])
respond_to do |format|
if @article.update_attributes(params[:article])
flash[:notice] = 'Article was successfully updated.'
format.html { redirect_to(@article) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @article.errors, :status
=> :unprocessable_entity }
end
end
end
# DELETE /articles/1
# DELETE /articles/1.xml
def destroy
@article = Article.find(params[:id])
@article.destroy
respond_to do |format|
format.html { redirect_to(articles_url) }
format.xml { head :ok }
end
end
end
I hope this helps. Though this class is pretty standard...
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.