Created
March 31, 2015 01:47
-
-
Save brunofonseca/bfef87278e3aa849d394 to your computer and use it in GitHub Desktop.
This file contains 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 | |
if user_signed_in? | |
@url = current_user.urls.new(url_params) | |
respond_to do |format| | |
if @url.save | |
format.html { redirect_to root_path } | |
format.json { render :show, status: :created, location: @url } | |
else | |
format.html { redirect_to root_path } | |
format.json { render json: @url.errors, status: :unprocessable_entity } | |
end | |
end | |
else | |
@url = Url.new(url_params) | |
@url.attributes = {user_id: '0'} | |
respond_to do |format| | |
if @url.save | |
#format.html { redirect_to root_path, notice: 'Link Salvo.' } | |
format.json { render json: @url.minaddress } | |
else | |
format.html { redirect_to root_path, notice: 'Link Invalido' } | |
format.json { render json: @url.errors } | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment