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.
Comments
Post a Comment