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
<?php | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateUsersTable extends Migration { | |
/** | |
* Run the migrations. | |
* |
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
<?php | |
public function listImage(){ | |
$listImages = $this->Image->find('all', | |
array( | |
'order' => array( | |
'Image.id' => 'desc'), | |
'limit' => 18)); | |
return $listImages; |
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:~/Music/radio_online/pyradio$ pip install pyradio | |
Downloading/unpacking pyradio | |
Downloading pyradio-0.5.2.tar.gz | |
Running setup.py egg_info for package pyradio | |
warning: no previously-included files found matching '*.pyc' | |
warning: no previously-included files found matching '*.orig' | |
Installing collected packages: pyradio | |
Running setup.py install for pyradio | |
deleting pyradio.egg-info/requires.txt |
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
<?php | |
/** | |
* edit method | |
* | |
* @throws NotFoundException | |
* @param string $id | |
* @return void | |
*/ | |
public function edit($id = null) { |
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
class Profile < ActiveRecord::Base | |
attr_accessible :birthday, :name, :user_id | |
#association | |
belongs_to :user | |
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
1.9.3-p484 :034 > article = Article.last | |
1.9.3-p484 :029 > category = Category.find_by_name('Pogramming') | |
Category Load (0.4ms) SELECT "categories".* FROM "categories" WHERE "categories"."name" = 'Pogramming' LIMIT 1 | |
=> nil | |
1.9.3-p484 :030 > article.categories << category | |
(0.1ms) begin transaction | |
(0.1ms) rollback transaction | |
ActiveRecord::AssociationTypeMismatch: Category(#28243960) expected, got NilClass(#4618340) | |
from /home/guinslym/.rvm/gems/ruby-1.9.3-p484@rails3tutorial2ndEd/gems/activerecord-3.2.16/lib/active_record/associations/association.rb:210:in `raise_on_type_mismatch' | |
from /home/guinslym/.rvm/gems/ruby-1.9.3-p484@rails3tutorial2ndEd/gems/activerecord-3.2.16/lib/active_record/associations/collection_association.rb:494:in `block in concat_records' |
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
1.9.3-p484 :034 > article = Article.last | |
Article Load (0.2ms) SELECT "articles".* FROM "articles" ORDER BY "articles"."id" DESC LIMIT 1 | |
=> #<Article id: 3, title: "Introduction to Active Record", body: "Active Record is Rails", published_at: "2014-01-12 05:00:00", created_at: "2014-01-12 08:39:41", updated_at: "2014-01-12 08:39:41", excerpt: nil, location: nil, user_id: nil> | |
1.9.3-p484 :035 > | |
1.9.3-p484 :029 > category = Category.find_by_name('Pogramming') | |
Category Load (0.4ms) SELECT "categories".* FROM "categories" WHERE "categories"."name" = 'Pogramming' LIMIT 1 | |
=> nil | |
1.9.3-p484 :030 > article.categories << category | |
(0.1ms) begin transaction |
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
__ __ ____ __ __ _ _____ ____ _____ ___ __ | |
| | | / | / ]| |/ ] / ___/ / || |/ _]| | | |
| | || o | / / | ' / ( \_ | o || __/ [_ | | | |
| _ || |/ / | \ \__ || || |_| _]|__| | |
| | || _ / \_ | \ / \ || _ || _] [_ __ | |
| | || | \ || . | \ || | || | | || | | |
|__|__||__|__|\____||__|\_| \___||__|__||__| |_____||__| | |
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
Hi! (1..9).to_a gives me an array. and [*1..9] gives me also an array but I don't understand the * character cause it's not a function where can I find the doc for * (does it have a special name cause I don't find the info in the doc) |
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
class CreateCategories < ActiveRecord::Migration | |
def change | |
create_table :categories do |t| | |
t.string :name, null: false | |
t.string :slug, null: false | |
t.integer :post_count, default: 0 | |
t.timestamps | |
end | |
end |