myspaceid-sdk 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. data/README +30 -0
  2. data/lib/myspace.rb +15 -0
  3. data/lib/myspace/exceptions.rb +31 -0
  4. data/lib/myspace/myspace.rb +565 -0
  5. data/lib/myspace/oauth.rb +62 -0
  6. data/lib/patches.rb +42 -0
  7. data/samples/rails/README +83 -0
  8. data/samples/rails/consumer_key.rb +4 -0
  9. data/samples/rails/consumer_key.rb-copyme +4 -0
  10. data/samples/rails/sample/README +256 -0
  11. data/samples/rails/sample/Rakefile +10 -0
  12. data/samples/rails/sample/app/controllers/application.rb +15 -0
  13. data/samples/rails/sample/app/controllers/oauth_controller.rb +68 -0
  14. data/samples/rails/sample/app/controllers/openid_controller.rb +105 -0
  15. data/samples/rails/sample/app/controllers/user_controller.rb +96 -0
  16. data/samples/rails/sample/app/helpers/application_helper.rb +3 -0
  17. data/samples/rails/sample/app/helpers/oauth_helper.rb +2 -0
  18. data/samples/rails/sample/app/helpers/openid_helper.rb +2 -0
  19. data/samples/rails/sample/app/helpers/user_helper.rb +90 -0
  20. data/samples/rails/sample/app/views/oauth/error.rhtml +8 -0
  21. data/samples/rails/sample/app/views/oauth/index.rhtml +8 -0
  22. data/samples/rails/sample/app/views/oauth/profile.rhtml +74 -0
  23. data/samples/rails/sample/app/views/openid/index.rhtml +125 -0
  24. data/samples/rails/sample/app/views/user/complete.rhtml +59 -0
  25. data/samples/rails/sample/app/views/user/index.rhtml +157 -0
  26. data/samples/rails/sample/config/boot.rb +109 -0
  27. data/samples/rails/sample/config/database.yml +22 -0
  28. data/samples/rails/sample/config/environment.rb +75 -0
  29. data/samples/rails/sample/config/environments/development.rb +17 -0
  30. data/samples/rails/sample/config/environments/production.rb +24 -0
  31. data/samples/rails/sample/config/environments/test.rb +22 -0
  32. data/samples/rails/sample/config/initializers/inflections.rb +10 -0
  33. data/samples/rails/sample/config/initializers/mime_types.rb +5 -0
  34. data/samples/rails/sample/config/initializers/new_rails_defaults.rb +17 -0
  35. data/samples/rails/sample/config/locales/en.yml +5 -0
  36. data/samples/rails/sample/config/routes.rb +43 -0
  37. data/samples/rails/sample/db/development.sqlite3 +0 -0
  38. data/samples/rails/sample/doc/README_FOR_APP +5 -0
  39. data/samples/rails/sample/public/404.html +30 -0
  40. data/samples/rails/sample/public/422.html +30 -0
  41. data/samples/rails/sample/public/500.html +33 -0
  42. data/samples/rails/sample/public/dispatch.cgi +10 -0
  43. data/samples/rails/sample/public/dispatch.fcgi +24 -0
  44. data/samples/rails/sample/public/dispatch.rb +10 -0
  45. data/samples/rails/sample/public/favicon.ico +0 -0
  46. data/samples/rails/sample/public/images/8b_Home.jpg +0 -0
  47. data/samples/rails/sample/public/images/8b_homecomp_200.jpg +0 -0
  48. data/samples/rails/sample/public/images/8b_profile_page_201.jpg +0 -0
  49. data/samples/rails/sample/public/images/LArge_150x35_myspaceID.png +0 -0
  50. data/samples/rails/sample/public/images/MySpaceID-loginwith-156x28.png +0 -0
  51. data/samples/rails/sample/public/images/appengine_button_noborder.gif +0 -0
  52. data/samples/rails/sample/public/images/background.png +0 -0
  53. data/samples/rails/sample/public/images/blue_150_Loginwithmyspaceid.png +0 -0
  54. data/samples/rails/sample/public/images/blue_150_signupwithmyspaceid.png +0 -0
  55. data/samples/rails/sample/public/images/blue_90_myspaceid.png +0 -0
  56. data/samples/rails/sample/public/images/button-background.gif +0 -0
  57. data/samples/rails/sample/public/images/grey_150_Loginwithmyspaceid.png +0 -0
  58. data/samples/rails/sample/public/images/grey_180_signupwithmyspaceid.png +0 -0
  59. data/samples/rails/sample/public/images/grey_90_myspaceid.png +0 -0
  60. data/samples/rails/sample/public/images/image.gif +0 -0
  61. data/samples/rails/sample/public/images/keyhole_buttons_only.png +0 -0
  62. data/samples/rails/sample/public/images/level_icon.png +0 -0
  63. data/samples/rails/sample/public/images/myspaceid.png +0 -0
  64. data/samples/rails/sample/public/images/nav_select.png +0 -0
  65. data/samples/rails/sample/public/images/openid-16x16.gif +0 -0
  66. data/samples/rails/sample/public/images/openid-icon.png +0 -0
  67. data/samples/rails/sample/public/images/openid-logo.png +0 -0
  68. data/samples/rails/sample/public/images/profile_icon.png +0 -0
  69. data/samples/rails/sample/public/images/profile_pic.png +0 -0
  70. data/samples/rails/sample/public/images/rails.png +0 -0
  71. data/samples/rails/sample/public/images/ranking_badge.png +0 -0
  72. data/samples/rails/sample/public/images/song_play.png +0 -0
  73. data/samples/rails/sample/public/images/song_sound.png +0 -0
  74. data/samples/rails/sample/public/images/star_grey.png +0 -0
  75. data/samples/rails/sample/public/images/star_yellow.png +0 -0
  76. data/samples/rails/sample/public/index.html +19 -0
  77. data/samples/rails/sample/public/index.html.orig +274 -0
  78. data/samples/rails/sample/public/javascripts/application.js +2 -0
  79. data/samples/rails/sample/public/javascripts/controls.js +963 -0
  80. data/samples/rails/sample/public/javascripts/dragdrop.js +973 -0
  81. data/samples/rails/sample/public/javascripts/effects.js +1128 -0
  82. data/samples/rails/sample/public/javascripts/myspaceid.rev.0.js +103 -0
  83. data/samples/rails/sample/public/javascripts/prototype.js +4320 -0
  84. data/samples/rails/sample/public/robots.txt +5 -0
  85. data/samples/rails/sample/public/stylesheets/base.css +46 -0
  86. data/samples/rails/sample/public/stylesheets/main.css +65 -0
  87. data/samples/rails/sample/public/stylesheets/openid.css +119 -0
  88. data/samples/rails/sample/script/about +4 -0
  89. data/samples/rails/sample/script/console +3 -0
  90. data/samples/rails/sample/script/dbconsole +3 -0
  91. data/samples/rails/sample/script/destroy +3 -0
  92. data/samples/rails/sample/script/generate +3 -0
  93. data/samples/rails/sample/script/performance/benchmarker +3 -0
  94. data/samples/rails/sample/script/performance/profiler +3 -0
  95. data/samples/rails/sample/script/performance/request +3 -0
  96. data/samples/rails/sample/script/plugin +3 -0
  97. data/samples/rails/sample/script/process/inspector +3 -0
  98. data/samples/rails/sample/script/process/reaper +3 -0
  99. data/samples/rails/sample/script/process/spawner +3 -0
  100. data/samples/rails/sample/script/runner +3 -0
  101. data/samples/rails/sample/script/server +3 -0
  102. data/samples/rails/sample/test/functional/oauth_controller_test.rb +8 -0
  103. data/samples/rails/sample/test/functional/openid_controller_test.rb +8 -0
  104. data/samples/rails/sample/test/functional/user_controller_test.rb +8 -0
  105. data/samples/rails/sample/test/performance/browsing_test.rb +9 -0
  106. data/samples/rails/sample/test/test_helper.rb +38 -0
  107. data/test/data.rb +8 -0
  108. data/test/myspace_test.rb +13 -0
  109. data/test/tc_albums.rb +126 -0
  110. data/test/tc_friends.rb +96 -0
  111. data/test/tc_profile.rb +107 -0
  112. data/test/tc_videos.rb +125 -0
  113. data/test/test_data.rb +14 -0
  114. data/test/ts_alltests.rb +7 -0
  115. metadata +222 -0
@@ -0,0 +1,62 @@
1
+ require 'openid/extension'
2
+ require 'openid/util'
3
+ require 'openid/message'
4
+ require 'oauth/token'
5
+
6
+ module MySpace
7
+ module OAuth
8
+ NS_URI = 'http://specs.openid.net/extensions/oauth/1.0'
9
+
10
+ # begin
11
+ # Message.register_namespace_alias(NS_URI, 'oauth')
12
+ # rescue NamespaceAliasRegistrationError => e
13
+ # Util.log(e)
14
+ # end
15
+
16
+ # An object to hold the state of a simple registration request.
17
+ class Request < OpenID::Extension
18
+ attr_reader :consumer, :scope, :ns_uri
19
+ def initialize(consumer, scope)
20
+ super()
21
+
22
+ @ns_uri = NS_URI
23
+ @ns_alias = 'oauth'
24
+ @consumer = consumer
25
+ @scope = scope
26
+ end
27
+
28
+ def get_extension_args
29
+ args = {}
30
+
31
+ args['consumer'] = @consumer
32
+ # args['scope'] = @scope
33
+
34
+ return args
35
+ end
36
+ end
37
+
38
+ # Represents the data returned in a simple registration response
39
+ # inside of an OpenID id_res response. This object will be
40
+ # created by the OpenID server, added to the id_res response
41
+ # object, and then extracted from the id_res message by the Consumer.
42
+ class Response < OpenID::Extension
43
+ attr_reader :ns_uri, :authorized_request_token
44
+
45
+ def initialize(request_token = nil)
46
+ @ns_uri = NS_URI
47
+ @ns_alias = 'oauth'
48
+ @authorized_request_token = request_token
49
+ end
50
+
51
+ # Create an Response object from an
52
+ # OpenID::Consumer::SuccessResponse from consumer.complete
53
+ # If you set the signed_only parameter to false, unsigned data from
54
+ # the id_res message from the server will be processed.
55
+ def self.from_success_response(success_response, oauth_consumer)
56
+ args = success_response.extension_response(NS_URI, nil)
57
+ new(::OAuth::RequestToken.new(oauth_consumer, args['request_token'], ''))
58
+ end
59
+ end
60
+ end
61
+ end
62
+
@@ -0,0 +1,42 @@
1
+ require 'rexml/element'
2
+ require 'rexml/formatters/default'
3
+
4
+ # fixes exception when element is too big to fit on a line
5
+ module REXML
6
+ module Formatters
7
+ # Pretty-prints an XML document. This destroys whitespace in text nodes
8
+ # and will insert carriage returns and indentations.
9
+ #
10
+ # TODO: Add an option to print attributes on new lines
11
+ class Pretty < Default
12
+ def wrap(string, width)
13
+ # p("wrap(" + string.to_s + "," + width.to_s + ")")
14
+ # Recursively wrap string at width.
15
+ return string if string.length <= width
16
+ place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
17
+ return string unless place # too wide, but no spaces to break
18
+ return string[0,place] + "\n" + wrap(string[place+1..-1], width)
19
+ end
20
+ end
21
+ end
22
+
23
+ class Document < Element
24
+ def pretty_print(q)
25
+ write($stdout, 2)
26
+ end
27
+ end
28
+ end
29
+
30
+
31
+ module OAuth::RequestProxy::Net
32
+ module HTTP
33
+ class HTTPRequest < OAuth::RequestProxy::Base
34
+ def query_string
35
+ params = [ query_params, auth_header_params ]
36
+ is_form_urlencoded = request['Content-Type'] != nil && request['Content-Type'].downcase == 'application/x-www-form-urlencoded'
37
+ params << post_params if ['POST', 'PUT'].include?(method.to_s.upcase) && is_form_urlencoded
38
+ params.compact.join('&')
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,83 @@
1
+ Overview of the samples in this directory:
2
+ -------------------------------------------
3
+
4
+ The samples have been unified into a single rails project for simplicity.
5
+
6
+ openid-combined-consumer:
7
+ -------------------------
8
+ This sample demonstrates an OpenID "Combined Consumer" by
9
+ implementing the openid/oauth "hybrid" spec as specified at:
10
+ http://step2.googlecode.com/svn/spec/openid_oauth_extension/latest/openid_oauth_extension.html
11
+
12
+ This sample also demostrates the interaction with MySpace using
13
+ the MySpace library to fetch the user's profile and friends data
14
+
15
+
16
+ oauth:
17
+ ------
18
+ This sample demonstrates an OAuth Consumer application by
19
+ implementing the oauth delegated access flow ("3 legged oauth").
20
+ Once the User authrizes the Consumer's request, it fetches the
21
+ user's profile and friend information using the library.
22
+
23
+ NOTE: Please note that in the samples above we store the access
24
+ token in the session. But, in a real application you would
25
+ probably need to store it an the user database so that you
26
+ can call the MySpace API methods in the future using the
27
+ stored access token
28
+
29
+ 8-bit Music:
30
+ ------------
31
+ This sample demonstrates using a popup window with directed
32
+ identity to do OpenID/OAuth without leaving the main page. It
33
+ also demonstrates activity streams.
34
+
35
+
36
+ Running the sample applications:
37
+ --------------------------------
38
+
39
+ The samples provided in this directory are based on Ruby on Rails
40
+ 2.2. Most of these files are boilerplate code generated by rails.
41
+ The main files to look at are:
42
+
43
+ sample/app/controllers/openid_controller.rb
44
+ sample/app/views/openid/index.rhtml
45
+
46
+ sample/app/controllers/oauth_controller.rb
47
+ sample/app/views/oauth/index.rhtml
48
+ sample/app/views/oauth/profile.rhtml
49
+
50
+ sample/app/controllers/user_controller.rb
51
+ sample/app/views/user/index.rhtml
52
+ sample/app/views/user/complete.rhtml
53
+ sample/public/javascripts/myspaceid.rev.0.js
54
+
55
+ To run the samples, please follow these steps:
56
+
57
+ 1. Type `server/start' from the sample root directory
58
+ (samples/rails/sample). This should fire up your local
59
+ instance of the web server and will start listening on port
60
+ 3000
61
+
62
+ 2. You can access the sample from your browser by navigating to
63
+ http://localhost:3000
64
+
65
+ The application key and secret that come with the SDK will only
66
+ work if you are running the web server on localhost, i.e. the same
67
+ machine as the web browser you are using. If you want to run the
68
+ code on a different machine, you must go to:
69
+
70
+ http://developer.myspace.com/modules/apps/pages/CreateAppAccount.aspx
71
+
72
+ to create a new MySpace application. Make sure to select the
73
+ "Create MySpaceID App" link and complete the application creation
74
+ process. Copy the new application's consumer key and secret to
75
+ the file consumer_key.rb located in the same directory as this
76
+ README.
77
+
78
+ IMPORTANT: The domain on which you run your server MUST be entered
79
+ as a realm on your MySpace app configuration page. In order for
80
+ the rails samples to work you MUST INCLUDE A SLASH AT THE END OF
81
+ YOUR DOMAIN, e.g. http://your-domain:3000/, when you enter it as a
82
+ realm.
83
+
@@ -0,0 +1,4 @@
1
+ module ConsumerKey
2
+ CONSUMER_KEY = '18bed0f4247a4f79bc9941bfed5b534c' unless const_defined?('CONSUMER_KEY')
3
+ CONSUMER_SECRET = '2e8ebdafbef844a5929086e659e4188c' unless const_defined?('CONSUMER_SECRET')
4
+ end
@@ -0,0 +1,4 @@
1
+ module ConsumerKey
2
+ CONSUMER_KEY = '' unless const_defined?('CONSUMER_KEY')
3
+ CONSUMER_SECRET = '' unless const_defined?('CONSUMER_SECRET')
4
+ end
@@ -0,0 +1,256 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to create
4
+ database-backed web applications according to the Model-View-Control pattern.
5
+
6
+ This pattern splits the view (also called the presentation) into "dumb" templates
7
+ that are primarily responsible for inserting pre-built data in between HTML tags.
8
+ The model contains the "smart" domain objects (such as Account, Product, Person,
9
+ Post) that holds all the business logic and knows how to persist themselves to
10
+ a database. The controller handles the incoming requests (such as Save New Account,
11
+ Update Product, Show Post) by manipulating the model and directing data to the view.
12
+
13
+ In Rails, the model is handled by what's called an object-relational mapping
14
+ layer entitled Active Record. This layer allows you to present the data from
15
+ database rows as objects and embellish these data objects with business logic
16
+ methods. You can read more about Active Record in
17
+ link:files/vendor/rails/activerecord/README.html.
18
+
19
+ The controller and view are handled by the Action Pack, which handles both
20
+ layers by its two parts: Action View and Action Controller. These two layers
21
+ are bundled in a single package due to their heavy interdependence. This is
22
+ unlike the relationship between the Active Record and Action Pack that is much
23
+ more separate. Each of these packages can be used independently outside of
24
+ Rails. You can read more about Action Pack in
25
+ link:files/vendor/rails/actionpack/README.html.
26
+
27
+
28
+ == Getting Started
29
+
30
+ 1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
31
+ and your application name. Ex: rails myapp
32
+ 2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
33
+ 3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
34
+ 4. Follow the guidelines to start developing your application
35
+
36
+
37
+ == Web Servers
38
+
39
+ By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
40
+ Rails will use WEBrick, the webserver that ships with Ruby. When you run script/server,
41
+ Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
42
+ that you can always get up and running quickly.
43
+
44
+ Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
45
+ suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
46
+ getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
47
+ More info at: http://mongrel.rubyforge.org
48
+
49
+ If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
50
+ Mongrel and WEBrick and also suited for production use, but requires additional
51
+ installation and currently only works well on OS X/Unix (Windows users are encouraged
52
+ to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
53
+ http://www.lighttpd.net.
54
+
55
+ And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
56
+ web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
57
+ for production.
58
+
59
+ But of course its also possible to run Rails on any platform that supports FCGI.
60
+ Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
61
+ please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
62
+
63
+
64
+ == Apache .htaccess example
65
+
66
+ # General Apache options
67
+ AddHandler fastcgi-script .fcgi
68
+ AddHandler cgi-script .cgi
69
+ Options +FollowSymLinks +ExecCGI
70
+
71
+ # If you don't want Rails to look in certain directories,
72
+ # use the following rewrite rules so that Apache won't rewrite certain requests
73
+ #
74
+ # Example:
75
+ # RewriteCond %{REQUEST_URI} ^/notrails.*
76
+ # RewriteRule .* - [L]
77
+
78
+ # Redirect all requests not available on the filesystem to Rails
79
+ # By default the cgi dispatcher is used which is very slow
80
+ #
81
+ # For better performance replace the dispatcher with the fastcgi one
82
+ #
83
+ # Example:
84
+ # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
85
+ RewriteEngine On
86
+
87
+ # If your Rails application is accessed via an Alias directive,
88
+ # then you MUST also set the RewriteBase in this htaccess file.
89
+ #
90
+ # Example:
91
+ # Alias /myrailsapp /path/to/myrailsapp/public
92
+ # RewriteBase /myrailsapp
93
+
94
+ RewriteRule ^$ index.html [QSA]
95
+ RewriteRule ^([^.]+)$ $1.html [QSA]
96
+ RewriteCond %{REQUEST_FILENAME} !-f
97
+ RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
98
+
99
+ # In case Rails experiences terminal errors
100
+ # Instead of displaying this message you can supply a file here which will be rendered instead
101
+ #
102
+ # Example:
103
+ # ErrorDocument 500 /500.html
104
+
105
+ ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
106
+
107
+
108
+ == Debugging Rails
109
+
110
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
111
+ will help you debug it and get it back on the rails.
112
+
113
+ First area to check is the application log files. Have "tail -f" commands running
114
+ on the server.log and development.log. Rails will automatically display debugging
115
+ and runtime information to these files. Debugging info will also be shown in the
116
+ browser on requests from 127.0.0.1.
117
+
118
+ You can also log your own messages directly into the log file from your code using
119
+ the Ruby logger class from inside your controllers. Example:
120
+
121
+ class WeblogController < ActionController::Base
122
+ def destroy
123
+ @weblog = Weblog.find(params[:id])
124
+ @weblog.destroy
125
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
126
+ end
127
+ end
128
+
129
+ The result will be a message in your log file along the lines of:
130
+
131
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
132
+
133
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
134
+
135
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
136
+
137
+ * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
138
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
139
+
140
+ These two online (and free) books will bring you up to speed on the Ruby language
141
+ and also on programming in general.
142
+
143
+
144
+ == Debugger
145
+
146
+ Debugger support is available through the debugger command when you start your Mongrel or
147
+ Webrick server with --debugger. This means that you can break out of execution at any point
148
+ in the code, investigate and change the model, AND then resume execution!
149
+ You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
150
+ Example:
151
+
152
+ class WeblogController < ActionController::Base
153
+ def index
154
+ @posts = Post.find(:all)
155
+ debugger
156
+ end
157
+ end
158
+
159
+ So the controller will accept the action, run the first line, then present you
160
+ with a IRB prompt in the server window. Here you can do things like:
161
+
162
+ >> @posts.inspect
163
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
164
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
165
+ >> @posts.first.title = "hello from a debugger"
166
+ => "hello from a debugger"
167
+
168
+ ...and even better is that you can examine how your runtime objects actually work:
169
+
170
+ >> f = @posts.first
171
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
172
+ >> f.
173
+ Display all 152 possibilities? (y or n)
174
+
175
+ Finally, when you're ready to resume execution, you enter "cont"
176
+
177
+
178
+ == Console
179
+
180
+ You can interact with the domain model by starting the console through <tt>script/console</tt>.
181
+ Here you'll have all parts of the application configured, just like it is when the
182
+ application is running. You can inspect domain models, change values, and save to the
183
+ database. Starting the script without arguments will launch it in the development environment.
184
+ Passing an argument will specify a different environment, like <tt>script/console production</tt>.
185
+
186
+ To reload your controllers and models after launching the console run <tt>reload!</tt>
187
+
188
+ == dbconsole
189
+
190
+ You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
191
+ You would be connected to the database with the credentials defined in database.yml.
192
+ Starting the script without arguments will connect you to the development database. Passing an
193
+ argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
194
+ Currently works for mysql, postgresql and sqlite.
195
+
196
+ == Description of Contents
197
+
198
+ app
199
+ Holds all the code that's specific to this particular application.
200
+
201
+ app/controllers
202
+ Holds controllers that should be named like weblogs_controller.rb for
203
+ automated URL mapping. All controllers should descend from ApplicationController
204
+ which itself descends from ActionController::Base.
205
+
206
+ app/models
207
+ Holds models that should be named like post.rb.
208
+ Most models will descend from ActiveRecord::Base.
209
+
210
+ app/views
211
+ Holds the template files for the view that should be named like
212
+ weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
213
+ syntax.
214
+
215
+ app/views/layouts
216
+ Holds the template files for layouts to be used with views. This models the common
217
+ header/footer method of wrapping views. In your views, define a layout using the
218
+ <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
219
+ call <% yield %> to render the view using this layout.
220
+
221
+ app/helpers
222
+ Holds view helpers that should be named like weblogs_helper.rb. These are generated
223
+ for you automatically when using script/generate for controllers. Helpers can be used to
224
+ wrap functionality for your views into methods.
225
+
226
+ config
227
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
228
+
229
+ db
230
+ Contains the database schema in schema.rb. db/migrate contains all
231
+ the sequence of Migrations for your schema.
232
+
233
+ doc
234
+ This directory is where your application documentation will be stored when generated
235
+ using <tt>rake doc:app</tt>
236
+
237
+ lib
238
+ Application specific libraries. Basically, any kind of custom code that doesn't
239
+ belong under controllers, models, or helpers. This directory is in the load path.
240
+
241
+ public
242
+ The directory available for the web server. Contains subdirectories for images, stylesheets,
243
+ and javascripts. Also contains the dispatchers and the default HTML files. This should be
244
+ set as the DOCUMENT_ROOT of your web server.
245
+
246
+ script
247
+ Helper scripts for automation and generation.
248
+
249
+ test
250
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
251
+ test files will be generated for you and placed in this directory.
252
+
253
+ vendor
254
+ External libraries that the application depends on. Also includes the plugins subdirectory.
255
+ If the app has frozen rails, those gems also go here, under vendor/rails/.
256
+ This directory is in the load path.