Last active
January 28, 2016 20:35
-
-
Save andreas-it-dev/74d377b66ff69f945b7c 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
<%= form_for @stock do |f| %> | |
<%= render "shared/errors", object: @stock %> | |
<div id="loginbox" class="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 user-box"> | |
<div class="panel panel-info"> | |
<div class="panel-heading"> | |
<div class="user-form-title panel-title"><%= purpose.to_s %></div> | |
</div> | |
<fieldset class="form-group"> | |
<%= f.label :symbol %> | |
<%= f.text_field :symbol, size: 50, autofocus: true, class: 'form-control' %> | |
</fieldset> | |
<fieldset class="form-group"> | |
<%= f.label :name %> | |
<%= f.text_field :name, size: 50, class: 'form-control' %> | |
</fieldset> | |
<fieldset class="form-group"> | |
<%= f.label :profile %> | |
<%= f.text_area :profile, size: 50, class: 'form-control' %> | |
</fieldset> | |
<fieldset class="form-group"> | |
<%= f.label :address %> | |
<%= f.text_field :address, size: 50, class: 'form-control' %> | |
</fieldset> | |
<fieldset class="form-group"> | |
<%= f.label :phone %> | |
<%= f.text_field :phone, size: 50, class: 'form-control' %> | |
</fieldset> | |
<fieldset class="form-group"> | |
<%= f.label :email %> | |
<%= f.text_field :email, size: 50, class: 'form-control' %> | |
</fieldset> | |
<fieldset class="form-group"> | |
<%= f.label :website %> | |
<%= f.text_field :website, size: 50, class: 'form-control' %> | |
</fieldset> | |
<% if @stock.new_record? %> | |
<%= f.submit 'Create Stock', class: 'button' %> | |
<%= link_to 'Cancel', :back, class: 'button' %> | |
<% else %> | |
<%= f.submit 'Update Stock', class: 'button' %> | |
<%= link_to 'Cancel', @analysis, class: 'button' %> | |
<% end %> | |
</div> | |
</div> | |
<% end %> |
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
Started PATCH "/stocks/1" for 127.0.0.1 at 2016-01-28 21:34:44 +0100 | |
Processing by StocksController#update as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"swHDUTgq5b7JFz1sjHmrP4rwlTVz/YvdrD3rJoPx9cNrfC0SD3l1esO6iMbnCFlHcgWGwe2VpbFPNDiEjE1vAQ==", "stock"=>{"symbol"=>"AAPL", "name"=>"Apple Inc", "profile"=>"Apple Inc. designs, manufactures, and markets mobile communication and media devices, personal computers, and portable digital music players to consumers, small and mid-sized businesses, education, and enterprise and government customers worldwide. The company also sells related software, services, accessories, networking solutions, and third-party digital content and applications. It offers iPhone, a line of smartphones; iPad, a line of multi-purpose tablets; and Mac, a line of desktop and portable personal computers. The company also provides iLife, a consumer-oriented digital lifestyle software application suite; iWork, an integrated productivity suite that helps users create, present, and publish documents, presentations, and spreadsheets; and other application software, such as Final Cut Pro, Logic Pro X, and FileMaker Pro. In addition, it offers Apple TV that connects to consumers\u0092 TV and enables them to access digital content directly for streaming high definition video, playing music and games, and viewing photos; Apple Watch, a personal electronic device; and iPod, a line of portable digital music and media players. Further, the company sells Apple-branded and third-party Mac-compatible, and iOS-compatible accessories, such as headphones, displays, storage devices, Beats products, and other connectivity and computing products and supplies. Additionally, it offers iCloud, a cloud service; AppleCare that offers support options for its customers; and Apple Pay, a mobile payment service. The company sells and delivers digital content and applications through the iTunes Store, App Store, iBooks Store, Mac App Store, and Apple Music. It also sells its products through its retail and online stores, and direct sales force, as well as through third-party cellular network carriers, wholesalers, retailers, and value-added resellers. Apple Inc. was founded in 1977 and is headquartered in Cupertino, California.", "address"=>"1 Infinite Loop Cupertino, CA 95014 United States", "phone"=>"408-996-1010", "email"=>"investor_relations@apple.com", "website"=>"http://www.apple.com"}, "commit"=>"Update Stock", "id"=>"1"} | |
Stock Load (0.3ms) SELECT "stocks".* FROM "stocks" WHERE "stocks"."id" = $1 LIMIT 1 [["id", 1]] | |
(0.1ms) BEGIN | |
Stock Exists (0.6ms) SELECT 1 AS one FROM "stocks" WHERE (LOWER("stocks"."symbol") = LOWER('AAPL') AND "stocks"."id" != 1) LIMIT 1 | |
(0.1ms) ROLLBACK | |
Rendered shared/_errors.html.erb (0.8ms) | |
Rendered stocks/_form.html.erb (5.5ms) | |
Rendered stocks/edit.html.erb within layouts/application (6.3ms) | |
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]] | |
Rendered layouts/_navigation.html.erb (1.6ms) | |
Rendered layouts/_flashes.html.erb (0.1ms) | |
Rendered layouts/_footer.html.erb (0.1ms) | |
Rendered /home/andreas/.gem/ruby/2.1.0/gems/cookies_eu-1.2.0/app/views/cookies_eu/_consent_banner.html.erb (0.2ms) | |
Completed 200 OK in 146ms (Views: 132.0ms | ActiveRecord: 1.4ms) |
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
class Stock < ActiveRecord::Base | |
validates :name, presence: true, length: {maximum: 50} | |
validates :symbol, presence: true, length: {maximum: 10}, :uniqueness => {case_sensitive: false} | |
before_validation :uppercase_symbol | |
has_many :constituents, dependent: :destroy | |
has_many :indexes, through: :constituents | |
has_many :daily_prices, as: :dailydata | |
private | |
def uppercase_symbol | |
self.symbol.upcase! | |
end | |
end |
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
Oops! The stock could not be saved. Please correct the following 1 error: | |
Symbol has already been taken |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment