2

以下に示すエラーが発生します。

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'
4

1 に答える 1

2

can you show us your code as refered in the error message? seems you put some wrong type of argument to a method that it couldn't handle it.

于 2012-10-31T10:58:42.493 に答える