Last active
December 11, 2015 07:08
-
-
Save tbuehlmann/4564148 to your computer and use it in GitHub Desktop.
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
class Domain < ActiveRecord::Base | |
attr_accessible :transport, :name | |
belongs_to :company | |
validates :name, new_domain: true, presence: true | |
end | |
def create | |
@company = Company.find(params[:company_id]) | |
@domain = @company.domains.build(params[:domain]) | |
respond_to do |format| | |
if @domain.save | |
format.html { redirect_to [@company, @domain], notice: 'Domain was successfully created.' } | |
format.json { render json: [@company, @domain], status: :created, location: @domain } | |
else | |
format.html { render action: "new" } | |
format.json { render json: @domain.errors, status: :unprocessable_entity } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment