ruby on rails - Render error on new page with customize url like http://localhost:3000/education_informations/new?user_id=10 -


i trying pass query parameter new action http://localhost:3000/education_informations/new?user_id=10 , set form validation on it. when form submit failed display error url changes http://localhost:3000/education_informations want same customize url , pass query parameter user_id. please me

controller code give below

def create     @edu_info = educationinformations.new(educational_params)          if @edu_info.save             #flash[:notice] = 'vote saved.'             redirect_to @edu_info         else             render 'new'         end       end 

you can pass parameters form_for below keep user_id in url after form submission failed.

<%= form_for @edu_info, :url => { :action => :create, :user_id => @user.id } %> 

or

<%= form_for @edu_info, :url => { :action => :create, :user_id => current_user.id } %> 

if @user not initialised.

source


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -