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')
Related
I am working in the following code. It is from the project 8agentball available in github (https://github.com/thinkpixellab/agent8ball).
I am a beginner in Ruby and Rails(started learning today), and I get an error when I try to execute it. I searched in the internet for over 4 hours and did not find anything.
- uncompiled = Rails.env == 'development' && params.has_key?('uncompiled')
- content_for :header do
= game_js(uncompiled)
%link{:rel => 'canonical', :href => 'http://agent8ball.com'}
%a#fork_me{:href => "https://github.com/thinkpixellab/agent8ball"}
%img{:alt => "Fork me on GitHub", :src => "http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"}
- if Rails.env == 'development'
- if(uncompiled)
= link_to "Uncompiled", root_path, :id => 'debug', :title => 'Go to compiled version'
- else
= link_to "Compiled", '/?uncompiled', :id => 'debug', :title => 'Go to uncompiled version'
And I get this error:
Showing
/Users/user/Documents/61/v4/agent8ball-master/app/views/main/index.haml
where line #xx raised:
/Users/user/Documents/61/v4/agent8ball-master/app/views/main/index.haml:xx: syntax error, unexpected keyword_ensure, expecting end-of-input
I tried indenting code, tried putting - end after if/else and/or do but to no use.
Any idea?
Thank you
I am following the Spree deface overrides developer guide: http://guides.spreecommerce.com/developer/deface_overrides_tutorial.html
My code matches their's exactly, but I keep getting this error. I looked all around but I didn't see anyone else having this problem or anything similar at all:
undefined method `content_tag' for Spree:Module
I am running Rails 4.0.2 and ruby 1.9.3 (it's possible that the tutorial wasn't updated for rails 4?)
here's my code:
app/overrides/add_sale_price_to_product_edit.rb
Deface::Override.new(:virtual_path => 'spree/admin/products/_form',
:name => 'add_sale_price_to_product_edit',
:insert_after => "erb[loud]:contains('text_field :price')",
:text => "
<%= f.field_container :sale_price do %>
<%= f.label :sale_price, raw(Spree.t(:sale_price)) %><span>*</span>
<%= f.text_field :sale_price, :value =>
number_to_currency(#product.sale_price, :unit => '') %>
<%= f.error_message_on :sale_price %>
<% end %>
")
app/models/spree/product_decorator.rb
module Spree
Product.class_eval do
delegate_belongs_to :master, :sale_price
end
end
You're getting the error because the translation for Spree.t(:sale_price) is not specified. This is failing because Rails 4.0.2 made some changes to the I18n API . You have a few choices.
Add a translation for the missing tag and remember that this content_tag issue is caused by this crazy bug.
Downgrade to Rails 4.0.0 (not recommended)
Upgrade spree to the 2-1-stable branch (or wait until 2.1.4 is released)
Apply this change to your local Spree installation. It should correct this issue.
Any of those should get you working again.
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
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?)
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