thrivesmart / bootscaf

Easily turn your rails generated scaffolds into fully bootstrappified views.
https://medium.com/@thrivesmart/bootscaf-easily-sexify-your-rails-scaffolds-to-use-bootstrap-d30c09d8649d
MIT License
22 stars 6 forks source link

undefined method `>=' for nil:NilClass #2

Open ekremkaraca opened 8 years ago

ekremkaraca commented 8 years ago

Hey guys,

I've installed bootscaf, make a scaffold run (for example, Post) and then I hit bootscaf update posts and finally I got error below:

Running on posts scaffolds.
/home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bootscaf-0.1.19/lib/bootscaf/cli.rb:96:in `update': undefined method `>=' for nil:NilClass (NoMethodError)
    from /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bootscaf-0.1.19/bin/bootscaf:3:in `<top (required)>'
    from /home/ekrem/.rbenv/versions/2.2.3/bin/bootscaf:23:in `load'
    from /home/ekrem/.rbenv/versions/2.2.3/bin/bootscaf:23:in `<main>'

I wonder what's wrong.

moorage commented 8 years ago

That line 96 is is_mac = (RbConfig::CONFIG['host_os'] =~ /^darwin/) >= 0

I didn't anticipate =~ returning nil. I think I just posted a patch; can you fetch the new version of the gem and let me know?

ekremkaraca commented 8 years ago

Seems OK after bootscaf is updated:

Running on posts scaffolds.
Would you like to update app/views/layouts/application.html.erb [y/n(default)]? y
Checking for most recent bootstrap cdn version... 3.3.5
Checking for most recent jquery cdn version... 2.1.4
Checking for most recent jquery-ui version... 1.11.4
Updating app/views/layouts/application.html.erb. 
Removing '//= require jquery' from app/assets/javascripts/application.js 
Would you like to overwrite scaffolds.css.scss with the bootrapified version [y/n(default)]? y
Wrote assets/stylesheets/scaffolds.css.scss
Would you like to use tablesorter [y(default)/n]? y
Wrote 41214 - app/assets/javascripts/jquery.tablesorter.js
Wrote 38 - app/assets/javascripts/jquery.tablesorterinit.js
Wrote assets/images/tablesorter-down.png
Wrote assets/images/tablesorter-up.png
Wrote assets/images/tablesorter.png
Wrote assets/stylesheets/tablesorter.css.scss
Would you like to make entire index.html.erb table rows clickable [y(default)/n]? y
Wrote 94 - app/assets/javascripts/table-linked-row.js
Wrote assets/stylesheets/table-linked-row.css.scss
Would you like to add a 'click to select-all' input element [y(default)/n]? y
Wrote 65 - app/assets/javascripts/select-all-on-click.js
Wrote assets/stylesheets/select-all-on-click.css.scss

Working on model:posts

Updating app/views/posts/_form.html.erb. 
Updating app/views/posts/edit.html.erb. 
Updating app/views/posts/index.html.erb. sed: -e expression #1, char 250: invalid reference \2 on `s' command's RHS

Updating app/views/posts/new.html.erb. 
Updating app/views/posts/show.html.erb. 

But there's another error occured while trying to edit posts:

Started GET "/posts/1/edit" for 127.0.0.1 at 2015-10-24 18:37:25 +0300
Processing by PostsController#edit as HTML
  Parameters: {"id"=>"1"}
  Post Load (0.1ms)  SELECT  "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT 1  [["id", 1]]
  Rendered posts/edit.html.erb within layouts/application (2.0ms)
Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.1ms)

SyntaxError (/home/ekrem/workspace/blog4/app/views/posts/edit.html.erb:3: `@,' is not allowed as an instance variable name
/home/ekrem/workspace/blog4/app/views/posts/edit.html.erb:3: syntax error, unexpected end-of-input
...\"></span> Cancel".html_safe, @, class: "btn btn-default" );...
...                               ^):
  app/views/posts/edit.html.erb:3: `@,' is not allowed as an instance variable name
  app/views/posts/edit.html.erb:3: syntax error, unexpected end-of-input

  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_source.erb (7.1ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.6ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.9ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (23.3ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/_markup.html.erb (0.2ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.3ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.2ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.2ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/console.js.erb within layouts/javascript (14.4ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/main.js.erb within layouts/javascript (0.3ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.3ms)
  Rendered /home/ekrem/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/index.html.erb (28.6ms)
moorage commented 8 years ago

Hmm... do you know what the line inapp/views/posts/edit.html.erb looked like before running bootscaf?

It's looking to match <%= link_to 'Show', @(.*) %> |

ekremkaraca commented 8 years ago

There's nothing look like <%= link_to 'Show', @(.*) %> | in edit.html.erb.

moorage commented 8 years ago

What about before running bootscaf? Did you use rails g scaffold to create your edit.html.erb view?

ekremkaraca commented 8 years ago

Yep, I run it. Now recognized that there's a line in edit.html.erb like:

<%= link_to 'Show', @post %> |
moorage commented 8 years ago

Pushed what I think is a fix, lemme know?

ekremkaraca commented 8 years ago

It's getting weird, here's new error:

Started GET "/articles" for 127.0.0.1 at 2015-10-24 19:48:11 +0300
  ActiveRecord::SchemaMigration Load (0.1ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by ArticlesController#index as HTML
  Rendered articles/index.html.erb within layouts/application (21.7ms)
Completed 500 Internal Server Error in 36ms (ActiveRecord: 0.0ms)

SyntaxError (/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:20: syntax error, unexpected '<', expecting '|'
 @articles.each do |<% content_for :page_title do ...
                     ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:20: syntax error, unexpected ':', expecting keyword_end
...icles.each do |<% content_for :page_title do ;@output_buffer...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:21: syntax error, unexpected '<'
...reeze;@output_buffer.append=  <% content_for :page_title do ...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:21: syntax error, unexpected ':', expecting keyword_end
...uffer.append=  <% content_for :page_title do @output_buffer....
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:27: formal argument cannot be a constant
 @articles.each do |Articles - | 
                            ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:27: syntax error, unexpected '-', expecting '|'
 @articles.each do |Articles - | 
                              ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:28: syntax error, unexpected ')'
...( Articles - _path(Articles - ) );@output_buffer.safe_append...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:34: syntax error, unexpected '<', expecting '|'
 @articles.each do |<% end ;@output_buffer.safe_append='| %>
                     ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:35: syntax error, unexpected '<'
...reeze;@output_buffer.append=( <% end );@output_buffer.safe_a...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:35: syntax error, unexpected keyword_end, expecting ')'
...afe_append='_path('.freeze; end ;@output_buffer.safe_append=...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:41: syntax error, unexpected '<', expecting '|'
 @articles.each do |<div class="container">| 
                     ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:41: syntax error, unexpected '|'
 @articles.each do |<div class="container">| 
                                            ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:42: syntax error, unexpected '<'
...reeze;@output_buffer.append=( <div class="container">_path(<...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:42: syntax error, unexpected '<', expecting ')'
... <div class="container">_path(<div class="container">) );@ou...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:42: syntax error, unexpected ')'
...>_path(<div class="container">) );@output_buffer.safe_append...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:48: syntax error, unexpected keyword_do_block, expecting ')'
 @articles.each do |<div class="page-header">| 
                  ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:48: syntax error, unexpected '|'
 @articles.each do |<div class="page-header">| 
                                              ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:49: syntax error, unexpected '<'
...reeze;@output_buffer.append=( <div class="page-header">_path...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:49: syntax error, unexpected '<', expecting ')'
...div class="page-header">_path(<div class="page-header">) );@...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:49: syntax error, unexpected ')'
...path(<div class="page-header">) );@output_buffer.safe_append...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:55: syntax error, unexpected keyword_do_block, expecting ')'
 @articles.each do |<h1>| 
                  ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:56: syntax error, unexpected '<'
...reeze;@output_buffer.append=( <h1>_path(<h1>) );@output_buff...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:56: syntax error, unexpected '<', expecting ')'
...put_buffer.append=( <h1>_path(<h1>) );@output_buffer.safe_ap...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:62: syntax error, unexpected keyword_do_block, expecting ')'
 @articles.each do |<div class="pull-left">| 
                  ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:62: syntax error, unexpected '|'
 @articles.each do |<div class="pull-left">| 
                                            ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:63: syntax error, unexpected '<'
...reeze;@output_buffer.append=( <div class="pull-left">_path(<...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:63: syntax error, unexpected '<', expecting ')'
... <div class="pull-left">_path(<div class="pull-left">) );@ou...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:63: syntax error, unexpected ')'
...>_path(<div class="pull-left">) );@output_buffer.safe_append...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:69: syntax error, unexpected keyword_do_block, expecting ')'
 @articles.each do |<%= link_to "<span class=\"...
                  ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:69: syntax error, unexpected $undefined, expecting ')'
... do |<%= link_to "<span class=\"glyphicon glyphicon-step-bac...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:69: syntax error, unexpected ',', expecting :: or '[' or '.'
...true\"></span>".html_safe, "/", class: "btn btn-default", ti...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:69: syntax error, unexpected ',', expecting ')'
... "/", class: "btn btn-default", title: "Back" ;@output_buffe...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:70: syntax error, unexpected '<'
...reeze;@output_buffer.append=( <%= link_to "<span class=\"gly...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:70: syntax error, unexpected $undefined, expecting ')'
...nd=( <%= link_to "<span class=\"glyphicon glyphicon-step-bac...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:70: syntax error, unexpected ',', expecting :: or '[' or '.'
...true\"></span>".html_safe, "/", class: "btn btn-default", ti...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:70: syntax error, unexpected ',', expecting ')'
... "/", class: "btn btn-default", title: "Back" );@output_buff...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:76: syntax error, unexpected '|'
 @articles.each do |&nbsp;| 
                           ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:77: syntax error, unexpected &
...reeze;@output_buffer.append=( &nbsp;_path(&nbsp;) );@output_...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:77: syntax error, unexpected ';', expecting ')'
...fer.append=( &nbsp;_path(&nbsp;) );@output_buffer.safe_appen...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:83: syntax error, unexpected '<', expecting '|'
 @articles.each do |</div>| 
                     ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:84: unknown regexp options - dv
end pattern with unmatched parenthesis: /div>| 
@output_buffer.safe_append='<tr class="linked-row" data-href="'.freeze;@output_buffer.append=( </i
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:84: syntax error, unexpected '<', expecting ')'
...t_buffer.append=( </div>_path(</div>) );@output_buffer.safe_...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:87: unknown regexp options - td
unmatched close parenthesis: /div>) );@output_buffer.safe_append='">
'.freeze; unless @articles.any? 
@output_buffer.safe_append='<tr id="empty-table">
<td class="bg-warning" colspan="2">No articles created yet.</
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:88: syntax error, unexpected '<'
</tr>
 ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:94: unknown regexp options - td
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:95: syntax error, unexpected '<'
</tr>
 ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:101: unknown regexp options - td
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:102: syntax error, unexpected '<'
</tr>
 ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:104: unknown regexp options - pa
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:104: syntax error, unexpected tCONSTANT, expecting keyword_do or '{' or '('
...en=\"true\"></span> New Article".html_safe, [:new, :article]...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:104: syntax error, unexpected tIDENTIFIER, expecting ')'
..., [:new, :article], class: "btn btn-success" ;@output_buffer...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:104: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
...icle], class: "btn btn-success" ;@output_buffer.safe_append=...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:105: syntax error, unexpected tIDENTIFIER, expecting ')'
<tr class="linked-row" data-href="'.freeze;@ou...
                 ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:105: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
<tr class="linked-row" data-href="'.freeze;@output_...
                      ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:105: syntax error, unexpected tIDENTIFIER, expecting ')'
...utput_buffer.safe_append='_path('.freeze;@output_buffer.appe...
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:105: syntax error, unexpected '>'
...output_buffer.safe_append=') %>">
...                               ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:107: syntax error, unexpected tIDENTIFIER, expecting ')'
@output_buffer.safe_append='<tr id="empty-table">
                                         ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:107: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
@output_buffer.safe_append='<tr id="empty-table">
                                                ^
/home/ekrem/workspace/blog4/app/views/articles/index.html.erb:108: syntax error, unexpected tIDENTIFIER, expecting ')'
<td class="bg-warning" colspan="2">No articles created yet.</td>

... and more. Probably, that one that causes error:

<% @articles.each do |<% content_for :page_title do %>| %>
moorage commented 8 years ago

wow very strange... i made an update so you can try again, but I can't even conceive how that would have happened.

any chance you can revert your scaffold views to what rails g scaffold had output, updqate the gem, and try again?

ekremkaraca commented 8 years ago

Now I'm able to access edit page but:

class

plus title of page is:

<div class="clearfix"></div>
<div class="pull-left">
<a class="btn btn-default" href="/posts/1"><span class="glyphicon glyphicon-ban-circle" aria-hidden="true"></span> Cancel</a>
</div>Edit Post - 
<div class="clearfix"></div>
<div class="pull-left">
<a class="btn btn-default" href="/posts/1"><span class="glyphicon glyphicon-ban-circle" aria-hidden="true"></span> Cancel</a>
</div>
<div class="clearfix"></div>
<div class="pull-left">
<a class="btn btn-default" href="/posts/1"><span class="glyphicon glyphicon-ban-circle" aria-hidden="true"></span> Cancel</a>
</div>Edit Post - 
<div class="clearfix"></div>
<div class="pull-left">
<a class="btn btn-default" href="/posts/1"><span class="glyphicon glyphicon-ban-circle" aria-hidden="true"></span> Cancel</a>
</div>Blog4
moorage commented 8 years ago

That is really really strange. It's working well on my Mac when I create a new rails app with a Post scaffold. What OS are you on?

ekremkaraca commented 8 years ago

It's Ubuntu 14.04 of course.

moorage commented 8 years ago

Hmm... I don't have Ubuntu 14.04 handy at the moment (any ubuntu). I have a feeling it's a difference between greedy and non-greedy matches perhaps between the two default sed versions (mac vs. linux).

Are you willing to run sed on your system to see what you get when you just run one line?

sed -i '' -e 's/<h1>Editing \(.*\)<\/h1>/<% content_for :page_title do %>\nEdit \1 - \n<% end %>\n<div class="container">\n<div class="page-header">\n<h1>Editing \1<\/h1>\n<\/div>/' app/views/posts/edit.html.erb

And see what the output onto edit.html.erb is?

ekremkaraca commented 8 years ago

Here it is:

sed -i '' -e 's/<h1>Editing \(.*\)<\/h1>/<% content_for :page_title do %>\nEdit \1 - \n<% end %>\n<div class="container">\n<div class="page-header">\n<h1>Editing \1<\/h1>\n<\/div>/' app/views/posts/edit.html.erb 
sed: can't read : No such file or directory
moorage commented 8 years ago

Oh, you'd have to run it from your project's root directory

ekremkaraca commented 8 years ago

I've already run it from project root directory. Even I've tried with full path:

➜  blog4 git:(master) ✗ sed -i '' -e 's/<h1>Editing \(.*\)<\/h1>/<% content_for :page_title do %>\nEdit \1 - \n<% end %>\n<div class="container">\n<div class="page-header">\n<h1>Editing \1<\/h1>\n<\/div>/' /home/ekrem/workspace/blog4/app/views/posts/edit.html.erb 
sed: can't read : No such file or directory
moorage commented 8 years ago

Well, I probably won’t be near a linux computer any time super soon, but would welcome a PR. My guess is that it has to do with replacing (.*)s with (.*?)s