Skip to content

Instantly share code, notes, and snippets.

@dissolved
Created July 28, 2011 21:33
Show Gist options
  • Save dissolved/1112622 to your computer and use it in GitHub Desktop.
Save dissolved/1112622 to your computer and use it in GitHub Desktop.
<h2>New Portfolio</h2>
<%= form_for @portfolio do |f| %>
<%= render 'shared/error_messages', :object => @portfolio %>
<div class="field" style="padding-top: 20px;">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field" style="padding-top: 20px;">
<%= f.label :beginning_cash_balance %><br />
<%= collection_select(:portfolio, :base_currency, Currency.all, :id, :description,
:selected => @portfolio.base_currency.id) %>
<%= f.text_field :cash, :value => number_with_precision(@portfolio.cash, :precision => 2) %>
</div>
<div class="field small">
<%= f.label :private %>
<%= f.check_box :private %>
<i>(Note, public portfolios only show percentages, not actual amounts)</i>
</div>
<div class="actions">
<%= f.submit "Create" %>
</div>
<% end -%>
.
.
.
def set_defaults
self.name ||= "Portfolio #{user.portfolios.count + 1}"
self.base_currency ||= Currency.find_by_code("USD")
end
.
.
.
.
.
.
# GET /portfolios/new[.format]
def new
@portfolio = @user.portfolios.build
@portfolio.set_defaults
end
.
.
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment