Created
April 10, 2012 19:01
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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