quadro 0.5.8 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/MIT-LICENSE +1 -1
- data/Rakefile +8 -10
- data/app/assets/javascripts/quadro/widget.js.coffee +12 -9
- data/app/controllers/quadro/application_controller.rb +22 -4
- data/app/controllers/quadro/assets_controller.rb +1 -1
- data/app/controllers/quadro/pages_controller.rb +1 -1
- data/app/controllers/quadro/{tools_controller.rb → sitemaps_controller.rb} +2 -2
- data/app/controllers/quadro/users_controller.rb +1 -1
- data/app/controllers/quadro/widgets_controller.rb +1 -1
- data/app/models/quadro/asset.rb +1 -1
- data/app/models/quadro/asset/cover.rb +2 -2
- data/app/models/quadro/asset/image.rb +2 -2
- data/app/models/quadro/asset/slide.rb +2 -2
- data/app/models/quadro/interaction.rb +1 -2
- data/app/models/quadro/page.rb +2 -3
- data/app/models/quadro/user.rb +2 -2
- data/app/models/quadro/widget.rb +0 -3
- data/app/models/quadro/widget/gallery.rb +0 -1
- data/app/models/quadro/widget/html.rb +0 -1
- data/app/models/quadro/widget/slider.rb +0 -1
- data/app/views/quadro/assets/image/_image.html.haml +1 -1
- data/app/views/quadro/assets/slide/_slide.html.haml +1 -1
- data/app/views/quadro/shared/_navigation.html.haml +2 -2
- data/app/views/quadro/shared/_toolbar.html.haml +2 -2
- data/app/views/quadro/shared/templates/_demo.html.haml +2 -0
- data/app/views/quadro/sitemaps/index.xml.builder +18 -0
- data/app/views/quadro/{tools/sitemap_notifier.js.erb → sitemaps/ping.js.erb} +0 -0
- data/config/initializers/simple_form.rb +46 -23
- data/config/initializers/simple_form_bootstrap.rb +124 -54
- data/config/locales/en.yml +1 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +5 -5
- data/lib/generators/quadro/install/templates/app/views/quadro/shared/_navigation.html.haml +1 -1
- data/lib/generators/quadro/install/templates/app/views/quadro/shared/templates/_demo.html.haml +2 -0
- data/lib/quadro/loader.rb +1 -3
- data/lib/quadro/version.rb +1 -1
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/test/dummy/README.rdoc +15 -248
- data/test/dummy/Rakefile +1 -2
- data/test/dummy/app/assets/javascripts/application.js +4 -6
- data/test/dummy/app/assets/stylesheets/application.css +6 -4
- data/test/dummy/app/controllers/application_controller.rb +3 -1
- data/test/dummy/app/views/layouts/application.html.erb +2 -2
- data/test/dummy/app/views/quadro/shared/_navigation.html.haml +2 -2
- data/test/dummy/app/views/quadro/shared/templates/_demo.html.haml +2 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +2 -2
- data/test/dummy/config/application.rb +3 -35
- data/test/dummy/config/boot.rb +4 -9
- data/test/dummy/config/database.yml +8 -8
- data/test/dummy/config/environment.rb +3 -3
- data/test/dummy/config/environments/development.rb +22 -18
- data/test/dummy/config/environments/production.rb +46 -34
- data/test/dummy/config/environments/test.rb +19 -14
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +6 -5
- data/test/dummy/config/initializers/mime_types.rb +0 -1
- data/test/dummy/config/initializers/session_store.rb +1 -6
- data/test/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/test/dummy/config/locales/en.yml +20 -2
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/{20160615055717_create_quadro_widgets.quadro.rb → 20160701222828_create_quadro_widgets.quadro.rb} +0 -0
- data/test/dummy/db/migrate/{20160615055718_create_quadro_pages.quadro.rb → 20160701222829_create_quadro_pages.quadro.rb} +0 -0
- data/test/dummy/db/migrate/{20160615055719_create_quadro_assets.quadro.rb → 20160701222830_create_quadro_assets.quadro.rb} +0 -0
- data/test/dummy/db/migrate/{20160615055720_devise_create_quadro_users.quadro.rb → 20160701222831_devise_create_quadro_users.quadro.rb} +0 -0
- data/test/dummy/db/migrate/{20160615055721_create_quadro_interactions.quadro.rb → 20160701222832_create_quadro_interactions.quadro.rb} +0 -0
- data/test/dummy/db/migrate/{20160619183944_add_published_at_field_on_quadro_pages.quadro.rb → 20160701222833_add_published_at_field_on_quadro_pages.quadro.rb} +0 -0
- data/test/dummy/db/schema.rb +36 -36
- data/test/integration/navigation_test.rb +0 -2
- data/test/test_helper.rb +9 -6
- metadata +201 -232
- data/README.md +0 -221
- data/app/assets/stylesheets/bootstrap/_mixins.scss +0 -40
- data/config/initializers/sitemap.rb +0 -9
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/log/test.log +0 -0
- data/test/dummy/script/rails +0 -6
@@ -1,79 +1,149 @@
|
|
1
|
-
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class
|
2
|
-
# https://github.com/plataformatec/simple_form/issues/316
|
3
|
-
|
4
|
-
inputs = %w[
|
5
|
-
CollectionSelectInput
|
6
|
-
DateTimeInput
|
7
|
-
FileInput
|
8
|
-
GroupedCollectionSelectInput
|
9
|
-
NumericInput
|
10
|
-
PasswordInput
|
11
|
-
RangeInput
|
12
|
-
StringInput
|
13
|
-
TextInput
|
14
|
-
]
|
15
|
-
|
16
|
-
inputs.each do |input_type|
|
17
|
-
superclass = "SimpleForm::Inputs::#{input_type}".constantize
|
18
|
-
|
19
|
-
new_class = Class.new(superclass) do
|
20
|
-
def input_html_classes
|
21
|
-
super.push('form-control')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
Object.const_set(input_type, new_class)
|
26
|
-
end
|
27
|
-
|
28
1
|
# Use this setup block to configure all options available in SimpleForm.
|
29
2
|
SimpleForm.setup do |config|
|
30
|
-
config.
|
3
|
+
config.error_notification_class = 'alert alert-danger'
|
4
|
+
config.button_class = 'btn btn-default'
|
5
|
+
config.boolean_label_class = nil
|
6
|
+
|
7
|
+
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
8
|
+
b.use :html5
|
9
|
+
b.use :placeholder
|
10
|
+
b.optional :maxlength
|
11
|
+
b.optional :pattern
|
12
|
+
b.optional :min_max
|
13
|
+
b.optional :readonly
|
14
|
+
b.use :label, class: 'control-label'
|
31
15
|
|
32
|
-
|
33
|
-
|
16
|
+
b.use :input, class: 'form-control'
|
17
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
18
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
19
|
+
end
|
34
20
|
|
21
|
+
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
35
22
|
b.use :html5
|
36
|
-
b.use :min_max
|
37
|
-
b.use :maxlength
|
38
23
|
b.use :placeholder
|
24
|
+
b.optional :maxlength
|
25
|
+
b.optional :readonly
|
26
|
+
b.use :label, class: 'control-label'
|
39
27
|
|
40
|
-
b.
|
28
|
+
b.use :input
|
29
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
30
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
31
|
+
end
|
32
|
+
|
33
|
+
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
34
|
+
b.use :html5
|
41
35
|
b.optional :readonly
|
42
36
|
|
43
|
-
b.
|
44
|
-
|
45
|
-
|
37
|
+
b.wrapper tag: 'div', class: 'checkbox' do |ba|
|
38
|
+
ba.use :label_input
|
39
|
+
end
|
40
|
+
|
41
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
42
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
46
43
|
end
|
47
44
|
|
48
|
-
config.wrappers :
|
45
|
+
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
46
|
+
b.use :html5
|
47
|
+
b.optional :readonly
|
48
|
+
b.use :label, class: 'control-label'
|
49
|
+
b.use :input
|
50
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
51
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
52
|
+
end
|
53
|
+
|
54
|
+
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
49
55
|
b.use :html5
|
50
56
|
b.use :placeholder
|
51
|
-
b.
|
52
|
-
b.
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
b.optional :maxlength
|
58
|
+
b.optional :pattern
|
59
|
+
b.optional :min_max
|
60
|
+
b.optional :readonly
|
61
|
+
b.use :label, class: 'col-sm-3 control-label'
|
62
|
+
|
63
|
+
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
64
|
+
ba.use :input, class: 'form-control'
|
65
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
66
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
58
67
|
end
|
59
68
|
end
|
60
69
|
|
61
|
-
config.wrappers :
|
70
|
+
config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
62
71
|
b.use :html5
|
63
72
|
b.use :placeholder
|
64
|
-
b.
|
65
|
-
b.
|
66
|
-
|
67
|
-
|
73
|
+
b.optional :maxlength
|
74
|
+
b.optional :readonly
|
75
|
+
b.use :label, class: 'col-sm-3 control-label'
|
76
|
+
|
77
|
+
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
78
|
+
ba.use :input
|
79
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
80
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
85
|
+
b.use :html5
|
86
|
+
b.optional :readonly
|
87
|
+
|
88
|
+
b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
|
89
|
+
wr.wrapper tag: 'div', class: 'checkbox' do |ba|
|
90
|
+
ba.use :label_input
|
68
91
|
end
|
69
|
-
|
70
|
-
|
92
|
+
|
93
|
+
wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
94
|
+
wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
99
|
+
b.use :html5
|
100
|
+
b.optional :readonly
|
101
|
+
|
102
|
+
b.use :label, class: 'col-sm-3 control-label'
|
103
|
+
|
104
|
+
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
105
|
+
ba.use :input
|
106
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
107
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
71
108
|
end
|
72
109
|
end
|
73
110
|
|
74
|
-
|
75
|
-
|
111
|
+
config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
112
|
+
b.use :html5
|
113
|
+
b.use :placeholder
|
114
|
+
b.optional :maxlength
|
115
|
+
b.optional :pattern
|
116
|
+
b.optional :min_max
|
117
|
+
b.optional :readonly
|
118
|
+
b.use :label, class: 'sr-only'
|
119
|
+
|
120
|
+
b.use :input, class: 'form-control'
|
121
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
122
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
123
|
+
end
|
124
|
+
|
125
|
+
config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
126
|
+
b.use :html5
|
127
|
+
b.optional :readonly
|
128
|
+
b.use :label, class: 'control-label'
|
129
|
+
b.wrapper tag: 'div', class: 'form-inline' do |ba|
|
130
|
+
ba.use :input, class: 'form-control'
|
131
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
132
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
133
|
+
end
|
134
|
+
end
|
135
|
+
# Wrappers for forms and inputs using the Bootstrap toolkit.
|
136
|
+
# Check the Bootstrap docs (http://getbootstrap.com)
|
76
137
|
# to learn about the different styles for forms and inputs,
|
77
138
|
# buttons and other elements.
|
78
|
-
config.default_wrapper = :
|
139
|
+
config.default_wrapper = :vertical_form
|
140
|
+
config.wrapper_mappings = {
|
141
|
+
check_boxes: :vertical_radio_and_checkboxes,
|
142
|
+
radio_buttons: :vertical_radio_and_checkboxes,
|
143
|
+
file: :vertical_file_input,
|
144
|
+
boolean: :vertical_boolean,
|
145
|
+
datetime: :multi_select,
|
146
|
+
date: :multi_select,
|
147
|
+
time: :multi_select
|
148
|
+
}
|
79
149
|
end
|
data/config/locales/en.yml
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
en:
|
2
|
+
simple_form:
|
3
|
+
"yes": 'Yes'
|
4
|
+
"no": 'No'
|
5
|
+
required:
|
6
|
+
text: 'required'
|
7
|
+
mark: '*'
|
8
|
+
# You can uncomment the line below if you need to overwrite the whole required html.
|
9
|
+
# When using html, text and mark won't be used.
|
10
|
+
# html: '<abbr title="required">*</abbr>'
|
11
|
+
error_notification:
|
12
|
+
default_message: "Please review the problems below:"
|
13
|
+
# Examples
|
14
|
+
# labels:
|
15
|
+
# defaults:
|
16
|
+
# password: 'Password'
|
17
|
+
# user:
|
18
|
+
# new:
|
19
|
+
# email: 'E-mail to sign in.'
|
20
|
+
# edit:
|
21
|
+
# email: 'E-mail.'
|
22
|
+
# hints:
|
23
|
+
# defaults:
|
24
|
+
# username: 'User name to sign in.'
|
25
|
+
# password: 'No special characters, please.'
|
26
|
+
# include_blanks:
|
27
|
+
# defaults:
|
28
|
+
# age: 'Rather not say'
|
29
|
+
# prompts:
|
30
|
+
# defaults:
|
31
|
+
# age: 'Select your age'
|
data/config/routes.rb
CHANGED
@@ -5,12 +5,12 @@ Quadro::Engine.routes.draw do
|
|
5
5
|
|
6
6
|
resource :user, only: [:edit, :update]
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
get 'atom.xml', to: 'feeds#atom', as: 'atom', format: 'xml'
|
9
|
+
get 'rss.xml', to: 'feeds#rss', as: 'rss', format: 'xml'
|
10
|
+
get 'sitemap.xml', to: 'sitemaps#index', as: 'sitemap', format: 'xml'
|
11
|
+
get 'robots.txt', to: 'robots#index', as: 'robots', format: 'txt'
|
12
12
|
|
13
|
-
get '
|
13
|
+
get 'sitemaps/ping', to: 'sitemaps#ping', as: 'ping'
|
14
14
|
|
15
15
|
resources :pages, path: '/' do
|
16
16
|
member do
|
@@ -8,9 +8,9 @@
|
|
8
8
|
= link_to root_path, class: 'navbar-brand' do
|
9
9
|
= Quadro.config.site
|
10
10
|
#navigation.collapse.navbar-collapse
|
11
|
-
= navigation_for root, class: "nav navbar-nav navbar-right"
|
12
11
|
- unless user_signed_in?
|
13
12
|
%ul.nav.navbar-nav.navbar-right
|
14
13
|
%li
|
15
14
|
= link_to new_user_session_path, rel: "nofollow" do
|
16
15
|
= t('navigation.sign_in')
|
16
|
+
= navigation_for root, class: "nav navbar-nav navbar-right"
|
data/lib/quadro/loader.rb
CHANGED
@@ -9,7 +9,6 @@ require "stringex"
|
|
9
9
|
require "devise"
|
10
10
|
require "paperclip"
|
11
11
|
require "configatron/core"
|
12
|
-
require "dynamic_sitemaps"
|
13
12
|
require "sitemap_notifier"
|
14
13
|
require "jquery-rails"
|
15
14
|
require "remotipart"
|
@@ -20,7 +19,7 @@ require "bootstrap-sass"
|
|
20
19
|
require "font-awesome-sass"
|
21
20
|
require "animate"
|
22
21
|
require "codemirror-rails"
|
23
|
-
require "summernote
|
22
|
+
require "summernote-rails"
|
24
23
|
require "jquery-slick-rails"
|
25
24
|
require "momentjs-rails"
|
26
25
|
require "gravatar_image_tag"
|
@@ -30,6 +29,5 @@ require "useragent"
|
|
30
29
|
require "maxminddb"
|
31
30
|
require "rails-i18n"
|
32
31
|
require "devise-i18n"
|
33
|
-
require "devise-i18n-views"
|
34
32
|
require "kaminari-i18n"
|
35
33
|
require "unobtrusive_flash"
|
data/lib/quadro/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
|
2
|
+
<%%= f.error_notification %>
|
3
|
+
|
4
|
+
<div class="form-inputs">
|
5
|
+
<%- attributes.each do |attribute| -%>
|
6
|
+
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
|
7
|
+
<%- end -%>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-actions">
|
11
|
+
<%%= f.button :submit %>
|
12
|
+
</div>
|
13
|
+
<%% end %>
|
data/test/dummy/README.rdoc
CHANGED
@@ -1,261 +1,28 @@
|
|
1
|
-
==
|
1
|
+
== README
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
5
|
|
6
|
-
|
7
|
-
templates that are primarily responsible for inserting pre-built data in between
|
8
|
-
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
-
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
-
persist themselves to a database. The controller handles the incoming requests
|
11
|
-
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
-
and directing data to the view.
|
6
|
+
Things you may want to cover:
|
13
7
|
|
14
|
-
|
15
|
-
layer entitled Active Record. This layer allows you to present the data from
|
16
|
-
database rows as objects and embellish these data objects with business logic
|
17
|
-
methods. You can read more about Active Record in
|
18
|
-
link:files/vendor/rails/activerecord/README.html.
|
8
|
+
* Ruby version
|
19
9
|
|
20
|
-
|
21
|
-
layers by its two parts: Action View and Action Controller. These two layers
|
22
|
-
are bundled in a single package due to their heavy interdependence. This is
|
23
|
-
unlike the relationship between the Active Record and Action Pack that is much
|
24
|
-
more separate. Each of these packages can be used independently outside of
|
25
|
-
Rails. You can read more about Action Pack in
|
26
|
-
link:files/vendor/rails/actionpack/README.html.
|
10
|
+
* System dependencies
|
27
11
|
|
12
|
+
* Configuration
|
28
13
|
|
29
|
-
|
14
|
+
* Database creation
|
30
15
|
|
31
|
-
|
32
|
-
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
16
|
+
* Database initialization
|
33
17
|
|
34
|
-
|
35
|
-
<tt>cd myapp; rails server</tt> (run with --help for options)
|
18
|
+
* How to run the test suite
|
36
19
|
|
37
|
-
|
38
|
-
"Welcome aboard: You're riding Ruby on Rails!"
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
39
21
|
|
40
|
-
|
41
|
-
the following resources handy:
|
22
|
+
* Deployment instructions
|
42
23
|
|
43
|
-
*
|
44
|
-
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
24
|
+
* ...
|
45
25
|
|
46
26
|
|
47
|
-
|
48
|
-
|
49
|
-
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
50
|
-
will help you debug it and get it back on the rails.
|
51
|
-
|
52
|
-
First area to check is the application log files. Have "tail -f" commands
|
53
|
-
running on the server.log and development.log. Rails will automatically display
|
54
|
-
debugging and runtime information to these files. Debugging info will also be
|
55
|
-
shown in the browser on requests from 127.0.0.1.
|
56
|
-
|
57
|
-
You can also log your own messages directly into the log file from your code
|
58
|
-
using the Ruby logger class from inside your controllers. Example:
|
59
|
-
|
60
|
-
class WeblogController < ActionController::Base
|
61
|
-
def destroy
|
62
|
-
@weblog = Weblog.find(params[:id])
|
63
|
-
@weblog.destroy
|
64
|
-
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
The result will be a message in your log file along the lines of:
|
69
|
-
|
70
|
-
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
71
|
-
|
72
|
-
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
73
|
-
|
74
|
-
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
75
|
-
several books available online as well:
|
76
|
-
|
77
|
-
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
78
|
-
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
79
|
-
|
80
|
-
These two books will bring you up to speed on the Ruby language and also on
|
81
|
-
programming in general.
|
82
|
-
|
83
|
-
|
84
|
-
== Debugger
|
85
|
-
|
86
|
-
Debugger support is available through the debugger command when you start your
|
87
|
-
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
88
|
-
execution at any point in the code, investigate and change the model, and then,
|
89
|
-
resume execution! You need to install ruby-debug to run the server in debugging
|
90
|
-
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
91
|
-
|
92
|
-
class WeblogController < ActionController::Base
|
93
|
-
def index
|
94
|
-
@posts = Post.all
|
95
|
-
debugger
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
So the controller will accept the action, run the first line, then present you
|
100
|
-
with a IRB prompt in the server window. Here you can do things like:
|
101
|
-
|
102
|
-
>> @posts.inspect
|
103
|
-
=> "[#<Post:0x14a6be8
|
104
|
-
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
105
|
-
#<Post:0x14a6620
|
106
|
-
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
107
|
-
>> @posts.first.title = "hello from a debugger"
|
108
|
-
=> "hello from a debugger"
|
109
|
-
|
110
|
-
...and even better, you can examine how your runtime objects actually work:
|
111
|
-
|
112
|
-
>> f = @posts.first
|
113
|
-
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
114
|
-
>> f.
|
115
|
-
Display all 152 possibilities? (y or n)
|
116
|
-
|
117
|
-
Finally, when you're ready to resume execution, you can enter "cont".
|
118
|
-
|
119
|
-
|
120
|
-
== Console
|
121
|
-
|
122
|
-
The console is a Ruby shell, which allows you to interact with your
|
123
|
-
application's domain model. Here you'll have all parts of the application
|
124
|
-
configured, just like it is when the application is running. You can inspect
|
125
|
-
domain models, change values, and save to the database. Starting the script
|
126
|
-
without arguments will launch it in the development environment.
|
127
|
-
|
128
|
-
To start the console, run <tt>rails console</tt> from the application
|
129
|
-
directory.
|
130
|
-
|
131
|
-
Options:
|
132
|
-
|
133
|
-
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
134
|
-
made to the database.
|
135
|
-
* Passing an environment name as an argument will load the corresponding
|
136
|
-
environment. Example: <tt>rails console production</tt>.
|
137
|
-
|
138
|
-
To reload your controllers and models after launching the console run
|
139
|
-
<tt>reload!</tt>
|
140
|
-
|
141
|
-
More information about irb can be found at:
|
142
|
-
link:http://www.rubycentral.org/pickaxe/irb.html
|
143
|
-
|
144
|
-
|
145
|
-
== dbconsole
|
146
|
-
|
147
|
-
You can go to the command line of your database directly through <tt>rails
|
148
|
-
dbconsole</tt>. You would be connected to the database with the credentials
|
149
|
-
defined in database.yml. Starting the script without arguments will connect you
|
150
|
-
to the development database. Passing an argument will connect you to a different
|
151
|
-
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
152
|
-
PostgreSQL and SQLite 3.
|
153
|
-
|
154
|
-
== Description of Contents
|
155
|
-
|
156
|
-
The default directory structure of a generated Ruby on Rails application:
|
157
|
-
|
158
|
-
|-- app
|
159
|
-
| |-- assets
|
160
|
-
| | |-- images
|
161
|
-
| | |-- javascripts
|
162
|
-
| | `-- stylesheets
|
163
|
-
| |-- controllers
|
164
|
-
| |-- helpers
|
165
|
-
| |-- mailers
|
166
|
-
| |-- models
|
167
|
-
| `-- views
|
168
|
-
| `-- layouts
|
169
|
-
|-- config
|
170
|
-
| |-- environments
|
171
|
-
| |-- initializers
|
172
|
-
| `-- locales
|
173
|
-
|-- db
|
174
|
-
|-- doc
|
175
|
-
|-- lib
|
176
|
-
| |-- assets
|
177
|
-
| `-- tasks
|
178
|
-
|-- log
|
179
|
-
|-- public
|
180
|
-
|-- script
|
181
|
-
|-- test
|
182
|
-
| |-- fixtures
|
183
|
-
| |-- functional
|
184
|
-
| |-- integration
|
185
|
-
| |-- performance
|
186
|
-
| `-- unit
|
187
|
-
|-- tmp
|
188
|
-
| `-- cache
|
189
|
-
| `-- assets
|
190
|
-
`-- vendor
|
191
|
-
|-- assets
|
192
|
-
| |-- javascripts
|
193
|
-
| `-- stylesheets
|
194
|
-
`-- plugins
|
195
|
-
|
196
|
-
app
|
197
|
-
Holds all the code that's specific to this particular application.
|
198
|
-
|
199
|
-
app/assets
|
200
|
-
Contains subdirectories for images, stylesheets, and JavaScript files.
|
201
|
-
|
202
|
-
app/controllers
|
203
|
-
Holds controllers that should be named like weblogs_controller.rb for
|
204
|
-
automated URL mapping. All controllers should descend from
|
205
|
-
ApplicationController which itself descends from ActionController::Base.
|
206
|
-
|
207
|
-
app/models
|
208
|
-
Holds models that should be named like post.rb. Models descend from
|
209
|
-
ActiveRecord::Base by default.
|
210
|
-
|
211
|
-
app/views
|
212
|
-
Holds the template files for the view that should be named like
|
213
|
-
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
214
|
-
eRuby syntax by default.
|
215
|
-
|
216
|
-
app/views/layouts
|
217
|
-
Holds the template files for layouts to be used with views. This models the
|
218
|
-
common header/footer method of wrapping views. In your views, define a layout
|
219
|
-
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
220
|
-
Inside default.html.erb, call <% yield %> to render the view using this
|
221
|
-
layout.
|
222
|
-
|
223
|
-
app/helpers
|
224
|
-
Holds view helpers that should be named like weblogs_helper.rb. These are
|
225
|
-
generated for you automatically when using generators for controllers.
|
226
|
-
Helpers can be used to wrap functionality for your views into methods.
|
227
|
-
|
228
|
-
config
|
229
|
-
Configuration files for the Rails environment, the routing map, the database,
|
230
|
-
and other dependencies.
|
231
|
-
|
232
|
-
db
|
233
|
-
Contains the database schema in schema.rb. db/migrate contains all the
|
234
|
-
sequence of Migrations for your schema.
|
235
|
-
|
236
|
-
doc
|
237
|
-
This directory is where your application documentation will be stored when
|
238
|
-
generated using <tt>rake doc:app</tt>
|
239
|
-
|
240
|
-
lib
|
241
|
-
Application specific libraries. Basically, any kind of custom code that
|
242
|
-
doesn't belong under controllers, models, or helpers. This directory is in
|
243
|
-
the load path.
|
244
|
-
|
245
|
-
public
|
246
|
-
The directory available for the web server. Also contains the dispatchers and the
|
247
|
-
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
248
|
-
server.
|
249
|
-
|
250
|
-
script
|
251
|
-
Helper scripts for automation and generation.
|
252
|
-
|
253
|
-
test
|
254
|
-
Unit and functional tests along with fixtures. When using the rails generate
|
255
|
-
command, template test files will be generated for you and placed in this
|
256
|
-
directory.
|
257
|
-
|
258
|
-
vendor
|
259
|
-
External libraries that the application depends on. Also includes the plugins
|
260
|
-
subdirectory. If the app has frozen rails, those gems also go here, under
|
261
|
-
vendor/rails/. This directory is in the load path.
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|