aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorSven Fuchs <svenfuchs@artweb-design.de>2008-08-25 11:11:08 +0200
committerSven Fuchs <svenfuchs@artweb-design.de>2008-08-25 11:11:08 +0200
commite464f9b6b93daa847a7d6fa1c3af63c8cef3f3e2 (patch)
tree6fcd3b1a2c30a2c25b85915af5a4277765f26858 /railties/lib
parent90a9637d41016c0d230ba36657e83a4f8d54cc46 (diff)
parentfb20d6f09d5e91280bf2b5888a7299b50dba7a7b (diff)
downloadrails-e464f9b6b93daa847a7d6fa1c3af63c8cef3f3e2.tar.gz
rails-e464f9b6b93daa847a7d6fa1c3af63c8cef3f3e2.tar.bz2
rails-e464f9b6b93daa847a7d6fa1c3af63c8cef3f3e2.zip
Merge commit 'rails/master' into i18n
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/commands/dbconsole.rb2
-rw-r--r--railties/lib/rails_generator/generated_attribute.rb4
-rw-r--r--railties/lib/rails_generator/generators/components/model/templates/model.rb3
3 files changed, 8 insertions, 1 deletions
diff --git a/railties/lib/commands/dbconsole.rb b/railties/lib/commands/dbconsole.rb
index 442526ae32..5be3b5dd8e 100644
--- a/railties/lib/commands/dbconsole.rb
+++ b/railties/lib/commands/dbconsole.rb
@@ -47,7 +47,7 @@ when "mysql"
args << config['database']
- exec(find_cmd('mysql5', 'mysql'), *args)
+ exec(find_cmd('mysql', 'mysql5'), *args)
when "postgresql"
ENV['PGUSER'] = config["username"] if config["username"]
diff --git a/railties/lib/rails_generator/generated_attribute.rb b/railties/lib/rails_generator/generated_attribute.rb
index 25af3931de..a3d4a01142 100644
--- a/railties/lib/rails_generator/generated_attribute.rb
+++ b/railties/lib/rails_generator/generated_attribute.rb
@@ -37,6 +37,10 @@ module Rails
""
end
end
+
+ def reference?
+ [ :references, :belongs_to ].include?(self.type)
+ end
end
end
end
diff --git a/railties/lib/rails_generator/generators/components/model/templates/model.rb b/railties/lib/rails_generator/generators/components/model/templates/model.rb
index 8d4c89e912..6fcf393bdf 100644
--- a/railties/lib/rails_generator/generators/components/model/templates/model.rb
+++ b/railties/lib/rails_generator/generators/components/model/templates/model.rb
@@ -1,2 +1,5 @@
class <%= class_name %> < ActiveRecord::Base
+<% attributes.select(&:reference?).each do |attribute| -%>
+ belongs_to :<%= attribute.name %>
+<% end -%>
end