ruby on rails - How Do I pass parameters with a render call? -


this simple question. if form isn't filled out correctly, call render 'new' in create action person can fill out form correctly. unfortunately, causes loss of parameters in url. how pass them along render call?

your action method should pick parameters , assign instance variable. model in example called note.

def create     @note = note.new(params[:note])     respond_to |format|       if @note.save         format.html { redirect_to @note, notice: 'note created.' }       else         format.html { render action: "new" }       end     end   end 

the instance variable visible within view:

<%= form_for(@note) |f| %>    <%= f.text_field :name %>    <%= f.submit %> <% end %> 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -