-
-
Save jonpaul/2353857 to your computer and use it in GitHub Desktop.
new and newlines
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 |
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
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 |
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
current_uri = Rails.application.routes.recognize_path(request.referrer) %> | |
if current_uri[:action] == 'new' | |
# format.html {render action: "new"} | |
format.json { render json: @karretlink.errors, status: :unprocessable_entity } | |
elsif current_uri[:action] == 'newlink' | |
format.html {render action: "newlink"} | |
format.json { render json: @karretlink.errors, status: :unprocessable_entity } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment