Skip to content

Instantly share code, notes, and snippets.

@richardsondx
Created April 10, 2012 19:01
Show Gist options
  • Save richardsondx/2353694 to your computer and use it in GitHub Desktop.
Save richardsondx/2353694 to your computer and use it in GitHub Desktop.
trying to render new or newline depending on what current page is currently viewed
def create
@karretlink = Karretlink.new(params[:karretlink])
respond_to do |format|
if @karretlink.save
format.html { redirect_to @karretlink, notice: 'Your Karret was successfully created.' }
format.json { render json: @karretlink, status: :created, location: @karretlink }
else
flash.now.alert = "Something went wrong, Make sure to fill up everything. ( Make sure Karet's name have no space or special symbol)"
current_uri = request.env['PATH_INFO']
if current_uri == new_path
# format.html {render action: "new"}
format.json { render json: @karretlink.errors, status: :unprocessable_entity }
elsif current_uri == newlink_path
format.html {render action: "newlink"}
format.json { render json: @karretlink.errors, status: :unprocessable_entity }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment