survey_generator 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/generators/survey/USAGE +10 -10
- data/lib/generators/survey/metamodels/survey_metamodel.rb +6 -5
- data/lib/generators/survey/survey_generator.rb +15 -15
- data/lib/generators/survey/templates/app/app.tpl +4 -6
- data/lib/generators/survey/templates/app/assets/assets.tpl +4 -0
- data/lib/generators/survey/templates/app/assets/stylesheets/stylesheet.tpl +188 -183
- data/lib/generators/survey/templates/app/controllers/application_controller.tpl +15 -0
- data/lib/generators/survey/templates/app/controllers/controllers.tpl +7 -0
- data/lib/generators/survey/templates/app/controllers/sessions_controller.tpl +26 -0
- data/lib/generators/survey/templates/app/controllers/static_pages_controller.tpl +20 -0
- data/lib/generators/survey/templates/app/controllers/survey_controller.tpl +0 -19
- data/lib/generators/survey/templates/app/controllers/users_controller.tpl +82 -0
- data/lib/generators/survey/templates/app/helpers/helpers.tpl +5 -0
- data/lib/generators/survey/templates/app/helpers/sessions_helper.tpl +46 -0
- data/lib/generators/survey/templates/app/helpers/users_helper.tpl +14 -0
- data/lib/generators/survey/templates/app/models/models.tpl +6 -0
- data/lib/generators/survey/templates/app/models/question.tpl +10 -0
- data/lib/generators/survey/templates/app/models/survey.tpl +10 -0
- data/lib/generators/survey/templates/app/models/test.tpl +15 -0
- data/lib/generators/survey/templates/app/models/user.tpl +28 -0
- data/lib/generators/survey/templates/app/views/layouts/footer.tpl +2 -2
- data/lib/generators/survey/templates/app/views/layouts/header.tpl +21 -13
- data/lib/generators/survey/templates/app/views/sessions/new.tpl +28 -0
- data/lib/generators/survey/templates/app/views/shared/error_messages.tpl +1 -1
- data/lib/generators/survey/templates/app/views/static_pages/home.tpl +1 -1
- data/lib/generators/survey/templates/app/views/survey/form.tpl +40 -0
- data/lib/generators/survey/templates/app/views/survey/index.tpl +40 -0
- data/lib/generators/survey/templates/app/views/survey/table.tpl +20 -0
- data/lib/generators/survey/templates/app/views/survey/textfield.tpl +21 -0
- data/lib/generators/survey/templates/app/views/users/edit.tpl +19 -0
- data/lib/generators/survey/templates/app/views/users/fields.tpl +24 -0
- data/lib/generators/survey/templates/app/views/users/index.tpl +17 -0
- data/lib/generators/survey/templates/app/views/users/new.tpl +15 -0
- data/lib/generators/survey/templates/app/views/users/show.tpl +15 -0
- data/lib/generators/survey/templates/app/views/users/user.tpl +11 -0
- data/lib/generators/survey/templates/app/views/views.tpl +11 -2
- data/lib/generators/survey/templates/config/routes.tpl +7 -0
- data/lib/generators/survey/templates/db/db.tpl +0 -1
- data/lib/generators/survey/templates/db/migrate/create_questions.tpl +5 -2
- data/lib/generators/survey/templates/db/migrate/create_surveys.tpl +4 -1
- data/lib/generators/survey/templates/db/migrate/create_users.tpl +1 -1
- data/lib/tasks/sample_data.rake +20 -0
- metadata +31 -11
- data/lib/generators/survey/templates/app/models/survey_model.tpl +0 -45
- data/lib/generators/survey/templates/app/views/survey/survey_form_view.tpl +0 -37
- data/lib/generators/survey/templates/app/views/survey/survey_index_view.tpl +0 -38
- data/lib/generators/survey/templates/db/migrate/create_pages.tpl +0 -18
@@ -1,45 +0,0 @@
|
|
1
|
-
<% define 'survey_model', for: Survey do %>
|
2
|
-
<% file "app/models/" + name.downcase + ".rb" do %>
|
3
|
-
class <%= name %> < ActiveRecord::Base
|
4
|
-
<%iinc%>attr_accessible :<%= title %>, :<%= author %><%nl%>
|
5
|
-
<% expand 'survey_page', foreach: pages %>
|
6
|
-
<%idec%>end
|
7
|
-
<% end %>
|
8
|
-
|
9
|
-
<% file "app/models/survey.rb" do %>
|
10
|
-
class Survey < ActiveRecord::Base<%iinc%>
|
11
|
-
attr_accessible :author, :name, :title, :user_id
|
12
|
-
|
13
|
-
<%nl%>
|
14
|
-
has_many :pages, dependent: :destroy
|
15
|
-
<%idec%>end
|
16
|
-
<% end %>
|
17
|
-
|
18
|
-
<% file "app/models/page.rb" do %>
|
19
|
-
class Page < ActiveRecord::Base<%iinc%>
|
20
|
-
attr_accessible :number, :survey_id, :title
|
21
|
-
|
22
|
-
<%nl%>
|
23
|
-
belongs_to :survey
|
24
|
-
has_many :questions, dependent: :destroy
|
25
|
-
<%idec%>end
|
26
|
-
<% end %>
|
27
|
-
|
28
|
-
<% file "app/models/question.rb" do %>
|
29
|
-
class Question < ActiveRecord::Base<%iinc%>
|
30
|
-
attr_accessible :content, :name, :page_id
|
31
|
-
|
32
|
-
<%nl%>
|
33
|
-
belongs_to :page
|
34
|
-
<%idec%>end
|
35
|
-
<% end %>
|
36
|
-
<% end %>
|
37
|
-
|
38
|
-
<% define 'survey_page', for: Page do %>
|
39
|
-
attr_accessible :<%= name %>
|
40
|
-
<% expand 'survey_question', foreach: questions %>
|
41
|
-
<% end %>
|
42
|
-
|
43
|
-
<% define 'survey_question', for: Question do %>
|
44
|
-
attr_accessible :<%= name %>, :<%= title %>
|
45
|
-
<% end %>
|
@@ -1,37 +0,0 @@
|
|
1
|
-
<% define 'survey_form_view', for: Survey do %>
|
2
|
-
<% file "app/views/" + name.pluralize.downcase + "/_form.html.erb" do %>
|
3
|
-
<%% @post.tags.build %>
|
4
|
-
<%%= form_for(@post) do |post_form| %>
|
5
|
-
<%iinc%><%% if @post.errors.any? %>
|
6
|
-
<%iinc%><div id="errorExplanation">
|
7
|
-
<%iinc%><h2><%%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
|
8
|
-
<ul>
|
9
|
-
<%% @post.errors.full_messages.each do |msg| %>
|
10
|
-
<%iinc%><li><%%= msg %></li>
|
11
|
-
<%idec%><%% end %>
|
12
|
-
</ul>
|
13
|
-
<%idec%></div>
|
14
|
-
<%idec%><%% end %><%nl%>
|
15
|
-
|
16
|
-
<div class="field">
|
17
|
-
<%iinc%><%%= post_form.label :name %><br />
|
18
|
-
<%%= post_form.text_field :name %>
|
19
|
-
<%idec%></div>
|
20
|
-
<div class="field">
|
21
|
-
<%iinc%><%%= post_form.label :title %><br />
|
22
|
-
<%%= post_form.text_field :title %>
|
23
|
-
<%idec%></div>
|
24
|
-
<div class="field">
|
25
|
-
<%iinc%><%%= post_form.label :content %><br />
|
26
|
-
<%%= post_form.text_area :content %>
|
27
|
-
<%idec%></div>
|
28
|
-
|
29
|
-
<%nl%><h2>Tags</h2>
|
30
|
-
<%%= render :partial => 'tags/form', :locals => {:form => post_form} %><%nl%>
|
31
|
-
|
32
|
-
<div class="actions">
|
33
|
-
<%iinc%><%%= post_form.submit %>
|
34
|
-
<%idec%></div>
|
35
|
-
<%idec%><%% end %>
|
36
|
-
<% end %>
|
37
|
-
<% end %>
|
@@ -1,38 +0,0 @@
|
|
1
|
-
<% define 'survey_index_view', for: Survey do %>
|
2
|
-
<% file "app/views/" + name.pluralize.downcase + "/index.html.erb" do %>
|
3
|
-
<%% provide(:title, "<%= title.capitalize %>") %>
|
4
|
-
<h1><%= title.capitalize %></h1>
|
5
|
-
|
6
|
-
<%nl%>
|
7
|
-
<div class="row"><%iinc%>
|
8
|
-
<div class="span6 offset3"><%iinc%>
|
9
|
-
<%%= form_tag <%= name.pluralize.downcase %>_path do %><%iinc%>
|
10
|
-
<%%# render 'shared/error_messages', object: f.object %>
|
11
|
-
<% expand 'survey_page', foreach: pages %>
|
12
|
-
<%idec%><%% end %>
|
13
|
-
|
14
|
-
<%nl%>
|
15
|
-
<div class="actions"><%%= submit_tag "Submit", class: "btn btn-large btn-primary" %></div>
|
16
|
-
<%idec%></div>
|
17
|
-
<%idec%></div>
|
18
|
-
<% end %>
|
19
|
-
<% end %>
|
20
|
-
|
21
|
-
<% define 'survey_page', for: Page do %>
|
22
|
-
<% expand 'survey_question', foreach: questions %>
|
23
|
-
<% end %>
|
24
|
-
|
25
|
-
<% define 'survey_question', for: Question do %>
|
26
|
-
<% expand 'survey_answer', foreach: answers %>
|
27
|
-
<% end %>
|
28
|
-
|
29
|
-
<% define 'survey_answer', for: Answer do %>
|
30
|
-
<% expand 'survey_answer_option', foreach: options %>
|
31
|
-
<% end %>
|
32
|
-
|
33
|
-
<% define 'survey_answer_option', for: AnswerOption do %>
|
34
|
-
<div class="field"><%iinc%>
|
35
|
-
<%%= label_tag :name, "<%= name %>" %>
|
36
|
-
<%%= text_field_tag :name %>
|
37
|
-
<%idec%></div>
|
38
|
-
<% end %>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<% define 'create_pages' do %>
|
2
|
-
<% file "db/migrate/create_pages.rb" do %>
|
3
|
-
class CreatePages < ActiveRecord::Migration<%iinc%>
|
4
|
-
def change<%iinc%>
|
5
|
-
create_table :pages do |t|<%iinc%>
|
6
|
-
t.string :title
|
7
|
-
t.integer :number
|
8
|
-
t.integer :survey_id
|
9
|
-
|
10
|
-
<%nl%>
|
11
|
-
t.timestamps
|
12
|
-
<%idec%>end
|
13
|
-
|
14
|
-
add_index :microposts, [:user_id, :created_at]
|
15
|
-
<%idec%>end
|
16
|
-
<%idec%>end
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|