call upload controller, but error will appears - ruby-on-rails

I'm coding with Ruby on rails 2.3.2 under BitNami RubyStack
When i call the upload controller, i get error like this:
compile error
C:/Users/BitNami RubyStack projects/killerapp/app/views/upload/index.html.erb:6: unterminated string meets end of file
C:/Users/BitNami RubyStack projects/killerapp/app/views/upload/index.html.erb:6: syntax error, unexpected $end, expecting ')'
The code of index view:
{ :multipart => true } do |form| %>
First_Name:
Last_Name:
What's the problem? Please, help me.

When I used 1.9 The problem didn't appear, but i like to use ruby 1.8.7

Related

Handling Routing Exception in Ruby on Rails

I am studying ruby on rails now and got stuck in exception handling. I just try to handle routing exceptions. I followed the following article
https://coderwall.com/p/whjmra/handling-exceptions-in-your-rails-application
In the code, id din't got the method 'render_exception(404, "Routing Error", exception)' . Please help me for this. I need to show my 404 page which is in the errors\404 in the view folder
When you handle exception try:
render :file => 'errors/404.html', :status => :not_found, :layout => false

How to resolve JSON syntax errors in rails?

I started learning rails using 'Agile Web Development with Rails, 4th Edition'
with
rails 3.2.7 and ruby 1.9.3p448 (2013-06-27 revision 41675) [i686-linux].
When i tried to
edit an html form with
<%= f.text_area :description :rows=>6 %>
it returned an error
/media/ashku/New Volume/RoR/depot/app/views/products/_form.html.erb:19: syntax error, unexpected ':', expecting ')'
...= ( f.text_area :description :rows=>6 );#output_buffer.safe...
then i tried to change the :rows=>6 to rows: 6 but the results where the same
Discussion here suggests it as problem with JSON
controller code is given here
so how to resolve this problem ?
You have missed the comma(,) after tag name ie.(:description).
So replace your tag with following and try to run..
<%= f.text_area :description, :rows => 6 %>
You're missing a comma in between :description, and :rows.
You can use "Better Errors" gem for debugging in development env., this is a better tool to find errors in good way. read about them from http://railscasts.com/episodes/402-better-errors-railspanel?view=asciicast

syntax error, unexpected ',', expecting tCOLON2 or '[' or '.' when assigning a class to erb

In my profile.html.erb file I get a syntax error anytime I try to assign a class or id to erb. Below is an example:
<p>"<%= current_user.current_program.name, :id => 'progress' %>" Progress</p>
This gives me the following error:
SyntaxError in Users#profile
Showing /.../app/views/users/profile.html.erb where line #13 raised:
/Users/.../app/views/users/profile.html.erb:13: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.'
...er.current_program.name, :id => 'progress' );#output_buffer....
... ^
I can't figure out what the syntax error is. I'm totally stumped.
We can reproduce and simplify your problem in a standalone Ruby like so:
require 'erb'
ERB.new("<p><%= name, :a => 'b' %></p>").run
Producing the error:
SyntaxError: (erb):1: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.'
..."; _erbout.concat(( name, :a => 'b' ).to_s); _erbout.concat ...
... ^
from /Users/phrogz/.../ruby/1.9.1/erb.rb:838:in `eval'
from /Users/phrogz/.../ruby/1.9.1/erb.rb:838:in `result'
from /Users/phrogz/.../ruby/1.9.1/erb.rb:820:in `run'
from (irb):2
from /Users/phrogz/.../bin/irb:16:in `<main>'
Even more simply, taking ERB out of the mix:
a, :b=>'c'
#=> SyntaxError: (irb):3: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.'
What you have just isn't valid Ruby code. What were you trying to do there? Pass the :id => 'progress' hash as a parameter to the .name method? If so, then drop the comma, and (optionally) include parentheses for clarity:
<p>"<%= current_user.current_program.name( :id=>'progress' ) %>" Progress</p>
And if you're using Ruby 1.9+, you can use the simpler Hash-with-symbol-keys syntax:
<p>"<%= current_user.current_program.name( id:'progress' ) %>" Progress</p>
However, it seems unlikely to me that the name method takes such a hash, so I ask again: what are you really trying to accomplish? What does the name method return, and what HTML output do you want?
Taking a guess, maybe you wanted the text returned by .name to be wrapped in <span id="progress">? If so, you must do so like:
<p>"<span id="progress"><%= current_user.current_program.name%></span>" Progress</p>
Or perhaps using content_tag:
<p><%= content_tag("span", current_user.current_program.name, id:'progress') %> Progress</p>
In Haml this would be:
%p
%span#progress= current_user.current_program.name
Progress
maybe if you remove the comma it will work (is current_user.current_program.name a method that takes a hash as a parameter?)

Rails link_to syntax error: unexpected ',', expecting ')'

I recently attempted to add bootstrap-sass to my rails app, and it seemed to have broken all my links (the links were fully functional before installing the bootstrap-sass gem). I am using ruby 1.8.7.
A sample link I have is:
<%=link_to image_tag ("right_arrow.png", :size => '20x20'), project_step_path(#project, #step.number+1) %>
The error I am getting is:
syntax error, unexpected ',', expecting ')' ...o(image_tag ("right_arrow.png", :size => '20x20'), project_s...
Anyone know how to fix this?
There is an extra-space after image_tag.
image_tag ("right_arrow.png", :size => '20x20')
It should be
image_tag("right_arrow.png", :size => '20x20')

Lots of syntax errors in HAML view (using spree engine)

I have this simple HAML view, admin.html.haml:
!!!
%html{:xmlns => "http://www.w3.org/1999/xhtml"}
%head{"data-hook" => "admin_inside_head"}
(the view is quite large, I deleted most of it for clarity)
Going to http://localhost:3000/admin I get:
SyntaxError in Spree/admin/overview#index
Showing /Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml where line #2 raised:
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:2: syntax error, unexpected '=', expecting ')'
...ut.attributes({}, nil, :xmlns => "http://www.w3.org/1999/...
... ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:2: syntax error, unexpected ')', expecting '}'
..."http://www.w3.org/1999/xhtml")}>\n <head#{_hamlout.adjust_...
... ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: syntax error, unexpected '=', expecting ')'
...tributes({}, nil, "data-hook" => "admin_inside_head")}></...
... ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: syntax error, unexpected ')', expecting '}'
...ook" => "admin_inside_head")}></head>\n</html>\n", -1, fa...
... ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: unknown regexp options - htl
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: syntax error, unexpected $undefined
...nside_head")}></head>\n</html>\n", -1, false);::Haml::Util.h...
... ^
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: unterminated string meets end of file
/Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml:3: syntax error, unexpected $end, expecting '}'
Extracted source (around line #2):
1: !!!
2: %html{:xmlns => "http://www.w3.org/1999/xhtml"}
3: %head{"data-hook" => "admin_inside_head"}
Trace of template inclusion: /Users/panayi/Dropbox/Sites/RAILS/engines/core/app/views/spree/layouts/admin.html.haml
The haml gem is loaded correctly (messing with the haml view indentation I get a Haml::SyntaxError), and it worked ok with erb views, before switching the spree views to haml.
Can anyone suggest what to check, to resolve the errors?
I spotted the problem:
Spree uses deface which is incompatible with HAML (see here).
The solution is to disable deface in the environment-specific config file (development.rb, production.rb, etc). Add this:
# Disable deface
config.deface.enabled = false

Resources