未定义的方法我有这个功能在我的控制器红宝石NoMethodError - 在控制器
def create
@tweet = Tweet.new(tweet_params)
@tweet.user_id = current_user.id
respond_to do |format|
if @tweet.save
format.html { redirect_to root_path, notice: "hello" }
format.js { render action: 'create', success: true, location: @tweet }
else
format.html { render action: 'show' }
format.js { render action: 'create', success: false }
end
end
end
形式设置为远程:真正的,所以这是我的create.js.erb
,但我得到了他的错误
NoMethodError (undefined method `tweet_url' for #<TweetsController:0x007f8de60e4b58>):
app/controllers/tweets_controller.rb:13:in `block (2 levels) in create'
app/controllers/tweets_controller.rb:9:in `create'
任何想法为什么这个错误显示?
能否请您发表您的routes文件尝试修改此来这样做呢? –
我认为这与'location:@ tweet'有关? – adamliesko