Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Some hacks to fix mixed case app names and NilNoMethod errors.

  • Loading branch information...
commit 82c1c91dd5f94a0e504e9499bfbddd4721b8d11e 1 parent 6074038
rbetina authored July 17, 2012
3  app
@@ -5,7 +5,8 @@ require './user_modifier.rb'
5 5
 require './layout_modifier.rb'
6 6
 require './association_builder.rb'
7 7
 
8  
-app_name = ARGV[0] || "MyApp"
  8
+# This downcase hack is to prevent mixed-case app name errors.
  9
+app_name = ARGV[0].downcase || "myapp"
9 10
 layout_name = ARGV[1] || "fixed"
10 11
 
11 12
 puts "Creating #{app_name} app."
4  association_builder.rb
@@ -42,7 +42,7 @@ def build_associations
42 42
           #TODO: Reading and/or writing need to be refactored into method.
43 43
           model_show = IO.readlines("#{@app_name}/app/views/#{model.pluralize.downcase}/show.html.erb")
44 44
           foreign_key_label_pos = model_show.map(&:strip).index("<dd><%= @#{model.downcase}.#{foreign_key}_id %></dd>")
45  
-          model_show[foreign_key_label_pos] = "  <dd><%= @#{model.downcase}.#{foreign_key}.#{descriptor} %></dd>"
  45
+          model_show[foreign_key_label_pos] = "  <dd><%= @#{model.downcase}.#{foreign_key} ? @#{model.downcase}.#{foreign_key}.#{descriptor} : nil %></dd>"
46 46
           f = File.new("#{@app_name}/app/views/#{model.pluralize.downcase}/show.html.erb", 'w')
47 47
           model_show.each { |line| f.puts line }
48 48
           f.close
@@ -51,7 +51,7 @@ def build_associations
51 51
 
52 52
           model_index = IO.readlines("#{@app_name}/app/views/#{model.pluralize.downcase}/index.html.erb")
53 53
           foreign_key_td_pos = model_index.map(&:strip).index("<td><%= #{model.downcase}.#{foreign_key}_id %></td>")
54  
-          model_index[foreign_key_td_pos] = "        <td><%= #{model.downcase}.#{foreign_key}.#{descriptor} %></td>"
  54
+          model_index[foreign_key_td_pos] = "        <td><%= #{model.downcase}.#{foreign_key} ? #{model.downcase}.#{foreign_key}.#{descriptor} : nil %></td>"
55 55
           f = File.new("#{@app_name}/app/views/#{model.pluralize.downcase}/index.html.erb", 'w')
56 56
           model_index.each { |line| f.puts line }
57 57
           f.close
3  layout_modifier.rb
@@ -39,7 +39,8 @@ def fix_misc
39 39
 
40 40
     footer_pos = application.map(&:strip).index("<p>&copy; Company 2012</p>")
41 41
     application[footer_pos] = "        <p>&copy; #{@app_name} 2012</p>"
42  
-
  42
+    
  43
+    #TODO: Capitalize breaks on mixed case app names.
43 44
     brand_pos = application.map(&:strip).index("<a class=\"brand\" href=\"#\">#{@app_name.capitalize}</a>")
44 45
     application[brand_pos] = "          <a class=\"brand\" href=\"<%= root_url %>\">#{@app_name.capitalize}</a>"
45 46
 
7  models.csv
... ...
@@ -1,4 +1,3 @@
1  
-User,email,password_digest,first_name,last_name
2  
-Lesson,name,embed_code,user_id:integer,
3  
-Question,content:text,lesson_id:integer,,
4  
-Vote,question_id:integer,user_id:integer,,
  1
+User,username,password_digest,facebook_access_token,twitter_access_token
  2
+Post,details:text,user_id:integer,source,video_id:integer
  3
+Video,url,host,author,
3  qs_models.csv
... ...
@@ -0,0 +1,3 @@
  1
+User,username,password_digest,facebook_access_token,twitter_access_token
  2
+Post,details:text,user_id:integer,source,video_id:integer
  3
+Video,url,host,author,

0 notes on commit 82c1c91

Please sign in to comment.
Something went wrong with that request. Please try again.