开发者

Ruby/Rails question about locating help/definitions w/in the system

开发者 https://www.devze.com 2023-01-02 10:24 出处:网络
This is probably super basic but, well, I can\'t find it... What\'s the best wa开发者_如何学编程y to explore Rails from within the installation itself. Let me explain. I\'m looking at some Migration

This is probably super basic but, well, I can't find it...

What's the best wa开发者_如何学编程y to explore Rails from within the installation itself. Let me explain. I'm looking at some Migration code and curious what a symbol means. How/where do I look that up? In this case, specifically, i'm curious about :force => true and what it's doing but the more general 'how do I go about answering this for myself w/out SO or Googling?' is the bigger question...

class CreateHomes < ActiveRecord::Migration
  def self.up
    create_table :homes, :force => true do |t|
      t.column :name, :string
      t.column :city, :string
    # ...
    end
  end
end


if you want to explore rails form your installation itself, perhaps you could use "gem server", it will open a local documentation server for your local gems

http://localhost:8808/

if you are looking for something about migrations (activerecord) for example, you'll have to access http://localhost:8808/doc_root/activerecord-2.3.8/rdoc/index.html

that's the easy way, or you could go into your gems directory and look the sources. (it's a nice thing to do sometimes)


I personally use APIdock for Rails docs due to it keeping track of deprecations, though it gets behind in versions sometimes. There may be another site that you end up liking better. There are several of them out there.

:force => true is an arg to create_table, which is documented here.


If you freeze your rails application then you will have all rails code within your vendor/rails directory. So when you are curious or do not know about how something really works under the hood then just search into that directory.

If you are not interested in code and only in documentation then you can use various online resources or gemserver locally. However, there is a nice gem called bdoc that you can use to view all locally installed gem in pretty format. You can set it up using http://nasir.wordpress.com/2009/09/22/pretty-rdocs-for-local-gems

0

精彩评论

暂无评论...
验证码 换一张
取 消