Skip to content

Instantly share code, notes, and snippets.

@jonpaul
Forked from richardsondx/this is what i tried
Created April 10, 2012 19:26
Show Gist options
  • Save jonpaul/2353857 to your computer and use it in GitHub Desktop.
Save jonpaul/2353857 to your computer and use it in GitHub Desktop.
new and newlines
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
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
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