gpt4 book ai didi

ruby-on-rails - 关于 TypeError 的错误(错误的参数类型模块(预期的类)): app/controllers/player_profiles_controller. rb:1:in `'

转载 作者:太空宇宙 更新时间:2023-11-03 16:06:17 25 4
gpt4 key购买 nike

我收到如下所示的错误:

TypeError (wrong argument type Module (expected Class)):
app/controllers/player_profiles_controller.rb:1:in `<top (required)>'

什么可能导致上面显示的错误?

我想通过在 SoapUI 中渲染 JSON 来测试结果。

这是错误

Started POST "/player_profiles/show" for 192.168.6.246 at 2012-11-02 10:14:15 +0700

TypeError (wrong argument type Module (expected Class)):
app/controllers/player_profiles_controller.rb:1:in `<top (required)>'


Rendered /home/gunarto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.e
rb (3.0ms)<br>
Rendered /home/gunarto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_request
_and_response.erb (2.3ms)<br>
Rendered /home/gunarto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/diagnost
ics.erb within rescues/layout (19.2ms)

player_profiles_controller.rb

class PlayerProfilesController < ActionController<br><br>

def register<br>
@player_profile = PlayerProfile.find(:first , :conditions => {:PlayerProfile => {:fullname => params[:fullname]}})<br>
if @player_profile == nil<br>
@player_profile = PlayerProfile.create(:fullname => params[:fullname], :nickname => params[:nickname],
:weight => params[:weight], :height => params[:height] ,
:bloodtype => params[:bloodtype], :teamname => params[:teamname],
:playerno => params[:playerno], :playerphoto => params[:playerphoto]) <br>
else<br>
@player_profile = PlayerProfile.find_by_sql("SELECT * FROM PlayerProfile WHERE fullname = '#{params[:fullname]}'")<br>
end<br>
render :json => {:result => @player_profile}<br>
end<br><br>

def show<br>
@player_profile = PlayerProfile.find_by_sql("SELECT * FROM PlayerProfile WHERE fullname= ? LIMIT 1 ",params[:fullname])<br>
render :json => {:result => @player_profile}<br>
end<br><br>

def delete<br>
@player_profile = PlayerProfile.destroy_all(:fullname => params[:fullname])<br>
render :json => {:result => @player_profile}<br>
end<br><br>

def update<br>
@player_profile = PlayerProfile.update_all(:fullname => params[:fullname], :nickname => params[:nickname],
:weight => params[:weight], :height => params[:height], :bloodtype => params[:bloodtype],
:teamname => params[:teamname], :playerno => params[:playerno] , :playerphoto => params[:playerphoto])<br>
head :ok , :content_type => 'application/json'<br>
end<br>
end

配置中的路由

post ':controller/:action' , :format => 'json'

最佳答案

您能向我们展示您在错误消息中引用的代码吗?似乎您将一些错误类型的参数放入它无法处理的方法中。

关于ruby-on-rails - 关于 TypeError 的错误(错误的参数类型模块(预期的类)): app/controllers/player_profiles_controller. rb:1:in `<top (required)>',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13155522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com