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
#how Do I do heritage in Model | |
class Account < ActiveRecord::Base | |
has_many :bookRentalInvoice | |
end | |
class CheckAccount < ActiveRecord::Base | |
belongs_to :account | |
end | |
class CreditAccount < ActiveRecord::Base |
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
#check to see if a hex String is null | |
"\u0080".unpack("h").each do |n| | |
a = n.to_i | |
if a.integer? && a.zero? | |
p n + " = this is an integer and it is empty" | |
else | |
p n + " not empty" | |
end | |
end |
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
2.0.0-p353 :042 > pages = Page.where(id: 48) | |
Page Load (0.4ms) SELECT `pages`.* FROM `pages` WHERE `pages`.`id` = 48 | |
=> #<ActiveRecord::Relation [#<Page id: 48, name: "---\n- français\n", parent_id: 36, created_at: "2014-01-22 00:33:48", updated_at: "2014-01-22 00:33:48">]> | |
2.0.0-p353 :043 > section = Section.where(page_id: 48).count | |
(0.3ms) SELECT COUNT(*) FROM `sections` WHERE `sections`.`page_id` = 48 | |
=> 3 | |
2.0.0-p353 :044 > pages.sections | |
NoMethodError: undefined method `sections' for #<ActiveRecord::Relation::ActiveRecord_Relation_Page:0x00000004f53c60> | |
from /home/guinslym/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/relation/delegation.rb:121:in `method_missing' | |
from /home/guinslym/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/relation/delegation.rb:68:in `method_missing' |
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
2.0.0-p353 :041 > pages = Page.find(52).sections.count | |
Page Load (0.3ms) SELECT `pages`.* FROM `pages` WHERE `pages`.`id` = 52 LIMIT 1 | |
(0.3ms) SELECT COUNT(*) FROM `sections` WHERE `sections`.`page_id` = 52 | |
=> 2 | |
2.0.0-p353 :042 > pages =Page.find(52).sections | |
Page Load (0.3ms) SELECT `pages`.* FROM `pages` WHERE `pages`.`id` = 52 LIMIT 1 | |
Section Load (0.2ms) SELECT `sections`.* FROM `sections` WHERE `sections`.`page_id` = 52 | |
=> #<ActiveRecord::Associations::CollectionProxy [#<Section id: 20, title: "La victoire est proche", body: "Guinsly t'e le meilleur Oat cake sweet roll browni...", page_id: 52, created_at: "2014-01-22 01:40:14", updated_at: "2014-01-22 01:40:14">, #<Section id: 36, title: "La victoire est proche", body: "Guinsly t'e le meilleur Oat cake sweet roll browni...", page_id: 52, created_at: "2014-01-22 01:40:15", updated_at: "2014-01-22 01:40:15">]> | |
2.0.0-p353 :044 > pages.each do |n| | |
2.0.0-p353 :045 > p.title |
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
#!/usr/bin/env ruby | |
# => Class | |
class Country | |
attr_accessor :continent, :country, :capital, :surface, :population | |
def initialize(liste) | |
@continent = liste.slice(0,1).to_i | |
@country = liste.slice(1,35).strip | |
@capital = liste.slice(36,20).strip |
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
guinslym@ubuntu:~/Documents/programming/project/impro2$ heroku logs | |
2014-02-02T20:25:33.909001+00:00 app[web.1]: from /app/config.ru:in `<main>' | |
2014-02-02T20:25:33.909001+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval' | |
2014-02-02T20:25:33.909001+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string' | |
2014-02-02T20:25:33.909001+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file' | |
2014-02-02T20:25:33.909001+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config' | |
2014-02-02T20:25:33.909001+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app' | |
2014-02-02T20:25:33.909001+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/commands/server.rb:48:in `app' | |
2014-02-02T20:25:33.909001+00:00 app[web |
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
CKEDITOR.editorConfig = function( config ) | |
{ | |
config.width = 450; | |
config.forcePasteAsPlainText = true; | |
config.autoGrow_onStartup = true; | |
config.autoGrow_minHeight = 300; | |
config.fillEmptyBlocks = false; | |
config.autoParagraph = false; | |
config.toolbar_mini = [ | |
['Format'], |
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
<div class="control-group"> | |
<%= f.label :location, :class => 'control-label' %> | |
<div class="controls"> | |
<%= f.select_tag :location, options_from_collection_for_select(Location.all, :parkname, :parkname) %> | |
</div> | |
</div> |
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
Ruby:: understanding | |
----------lambda & Proc | |
Article.find_each(&:save) | |
---Is this a lambda, a proc? I don't understand it. I know what it does but what means the ":save" i didn't create a function to be yield | |
Rails:: Association | |
4.3.2.3 :class_name | |
http://guides.rubyonrails.org/association_basics.html | |
I don't understand this | |
"If the name of the other model cannot be derived from the association name, you can use the :class_name option to supply the model name. For example, if a customer has many orders, but the actual name of the model containing orders is Transaction, you'd set things up this way:" |
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
Gemfile | |
... | |
gem 'nokogiri' | |
... | |
In controller |