ruby on rails - NoMethodError: undefined method `model_name' for Fixnum:Class -


i run rspec testcase fills form , submits it. following error:

1) sign advertiser after adding valid information should create user    failure/error: expect { click_button submit }.to change(user, :user_key)    nomethoderror:      undefined method `model_name' fixnum:class    # /mnt/hgfs/projekte/adserve.example.de/app/controllers/advertisers_controller.rb:31:in `trytocreateuser'    # /mnt/hgfs/projekte/adserve.example.de/app/controllers/advertisers_controller.rb:14:in `create'    # ./sign_up_advertiser_spec.rb:32:in `block (4 levels) in <top (required)>'    # ./sign_up_advertiser_spec.rb:32:in `block (3 levels) in <top (required)>' 

this code controller:

class advertiserscontroller < applicationcontroller   ...    def home     @menuindex = 0   end    def create     @user = advertiser.new (params[:advertiser])     trytocreateuser   end    def trytocreateuser     if @user.save       @user = advertiser.retrieve(@user.id)        redirect_to home, :notice => "you signed " + @user.full_name     else       render :action => "/users/new", :layout => 'application'     end   end end 

and routes.rb looks like

match "signup_advertiser" => "advertisers#new", :as => "signup_advertiser" match "signup_publisher" => "publishers#new", :as => "signup_publisher"  "advertisers_home" => "advertisers#home"  resources :advertisers 

so guess mistake in redirect_to part. can't figure out. fiddled around rendering custom action in 'home' , other stuff. think it's pretty basic appreciated. thanks.

yes, problem there. should use home symbol on redirect_to method:

def trytocreateuser   if @user.save     @user = advertiser.retrieve(@user.id)     redirect_to :home, :notice => "you signed " + @user.full_name   else     render :action => "/users/new", :layout => 'application'   end end 

what is: redirect_to 0 since calling controllers method "home".


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -