The action could not be found for controller
Having gone through my code I have a separate problem from my original question and rather than writing a new question. I will leave the old part at the bottom of this and post the new problem here. I do this because they are closely related.
New:
Im getting an error message saying
Unknown acti开发者_JAVA百科on
The action 'response' could not be found for CrawlerController
I'll keep it simple but the code for model, controller and routes are below in the previous question.
A basic run down is response is a def within CrawlerController as is add_Request. The routes are matched as such:
match "/requests/new" => "crawler#add_Request"
match 'requests/:id' => 'crawler#response'
Here is controller code as per user request:
class CrawlerController < ApplicationController
def add_Request
@request = Request.new(params[:request])
respond_to do |format|
if @request.save
format.html { redirect_to(@request, :notice => 'Request was successfully created.') }
format.xml { render :xml => @request, :status => :created, :location => @request }
else
format.html { render :action => "new" }
format.xml { render :xml => @request.errors, :status => :unprocessable_entity }
end
end
end
def response
@request = Request.find(params[:id])
respond_to do |format|
format.html
format.js { render :json => @request }
end
end
def show
@request = Request.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @request }
format.json{
render :json => @request.to_json
}
end
end
end
please recheck code of controller as I can see it
class CrawlerController < ApplicationController
def add_Request
@request = Request.new(params[:request])
respond_to do |format|
if @request.save
format.html { redirect_to(@request, :notice => 'Request was successfully created.') }
format.xml { render :xml => @request, :status => :created, :location => @request }
else
format.html { render :action => "new" }
format.xml { render :xml => @request.errors, :status => :unprocessable_entity }
end
end
def response
@request = Request.find(params[:id])
respond_to do |format|
format.json {render :@request.to_json}
end
end
so one end is missing an your response
action is defined inside add_Request
精彩评论