def create @emppede = Emppede.new(params[:emppede]) respond_to do |format| if @emppede.save format.html { redirect_to :action => :index, :id => @emppede.ad } format.json { render json: @emppede, status: :created, location: @emppede } else format.html { render action: "new", :id => @emppede.ad } *(....error)* format.json { render json: @emppede.errors, status: :unprocessable_entity } end end end
I need to pass id to a new method. Here, if the data is stored correctly, it goes to the index method. But if not, then it should go to the new one, but with the id parameter. How can I pass parameters using the render action? Here I want to do, but param id is not passed to the new method. I highlighted this part by mistake. If i do
format.html { redirect_to :action => :new, :id => @emppede.ad }
Then it does not report errors ...
I need to pass the user id to the new method so that I can pass it through the form and save.
<div id="employm" style="display:none"> <%= f.text_field :ad, :value=> @id%> </div>
But when the get error form prints to a new one, but here I have to send the id, which is in @emppede.ad . How can i do this? Since id must be passed to enter a new method
redirect_to :action => :new, :id => @id
source share