Skip to content

Instantly share code, notes, and snippets.

@tbuehlmann
Last active December 11, 2015 07:08
Show Gist options
  • Save tbuehlmann/4564148 to your computer and use it in GitHub Desktop.
Save tbuehlmann/4564148 to your computer and use it in GitHub Desktop.
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