Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

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