Skip to content
Browse files

Links#new puts default subdomain in placeholder

  • Loading branch information...
1 parent 2bdd57f commit d21f2814d6a6bdc0202c4d75e8145a8ad426d6e6 @nmanzi committed Oct 9, 2011
Showing with 4 additions and 1 deletion.
  1. +2 −0 app/controllers/links_controller.rb
  2. +2 −1 app/views/links/_form.html.erb
View
2 app/controllers/links_controller.rb
@@ -24,6 +24,7 @@ def show
# GET /links/new.json
def new
@link = Link.new
+ @default_subdomain = @link.subdomain
respond_to do |format|
format.html # new.html.erb
@@ -40,6 +41,7 @@ def edit
# POST /links.json
def create
@link = Link.new(params[:link])
+ @link.subdomain = params[:default_subdomain] if @link.subdomain.empty?
respond_to do |format|
if @link.save
View
3 app/views/links/_form.html.erb
@@ -13,7 +13,8 @@
<div class="clearfix <%= @link.errors[:subdomain].present? ? 'error' : nil %>">
<%= f.label :subdomain %>
<div class="input">
- <%= f.text_field :subdomain %>
+ <%= hidden_field_tag "default_subdomain", @default_subdomain %>
+ <%= f.text_field :subdomain, :placeholder => @default_subdomain, :value => (@link.subdomain unless @link.subdomain == @default_subdomain) %>
<span class="help-inline">Enter without the parent domain, e.g. subbysub NOT subbysub.hadric.us</span>
<% @link.errors[:subdomain].each do |msg| %>
<span class="help-block"><%= msg.capitalize %>!</span>

0 comments on commit d21f281

Please sign in to comment.
Something went wrong with that request. Please try again.