ruby on rails - undefined local variable or method `resource' for for Simple_Form -


i have users controller these 2 methods

  def trial_signup     @user = user.new    end     def trial_signup_submit     @user = user.create(params[:user_attributes])   end  

my trial_signup.html.erb (simple_form) in app/views/users

here part of form

<%= simple_form_for(resource, :as => resource_name, :url => users_trial_signup_submit_path(resource_name)) |f| %> 

in routes added these

  'users/trial_signup', to: 'users#trial_signup'   post 'users/trial_signup_submit', to: 'users#trial_signup_submit' 

my form getting rendered correctly not posting correctly. want post actions created.

i have devise installed. have signup work flow registering user trial signup need find way.

why form not being able find user model resource?

<%= simple_form_for(@user, :url => users_trial_signup_submit_path(@user)) |f| %> 

you're trying render devise form outside of devise controller, don't have initialized resource nor resource_name variables.

probably, need change params in controller too:

def trial_signup_submit   @user = user.create(params[:user]) end 

although recommend that:

def trial_signup_submit   @user = user.new(params[:user])   if @user.save     redirect_to <wherever want>, notice: <your message>   else     render :trial_signup   end end 

ps: think should change actions new_trial , create_trial, if need different defaults new , create.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -