I am getting a weird syntax error from rails that I don't understand.
GETTING THE FOLLOWING ERROR:
Showing /home/action/workspace/clinio/app/views/tasks/_task.html.erb where line #3 raised:
/home/action/workspace/clinio/app/views/tasks/_task.html.erb:3: syntax error, unexpected ';', expecting ':'
';#output_buffer.append=( image...
^
Extracted source (around line #3):
<% #uncompletedtasks = #task if #uncompletedtasks?%>
<li id="task_">
<div><%= image_tag "26-mini-gray-checkmark.png" %>
<%= #uncompletedtasks.task %>
</div>
</li>
Trace of template inclusion: app/views/tasks/_task.html.erb, app/views/layouts/application.html.erb
Rails.root: /home/action/workspace/clinio
Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:35:in _app_views_layouts_application_html_erb__122972711486791642_46610700'
app/controllers/users_controller.rb:16:inindex'
You don't need that question mark at the end.
<% #uncompletedtasks = #task if #uncompletedtasks %>
(the purpose of this code still eludes me, though. Why would you want overwrite #uncompletedtasks only if it has value?)
Related
I have written a rails application but when running rails server I am getting following error
"syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '(' ...? ? render("result") : Your url have a problem );#output_buf... ... ^"
</div>
</div>
<%= #links.present? ? render("result") : Your url have a problem %>
</div>
You need to enclose strings between " " or ' ' otherwise they will be treated as variables (or classes); Your url have a problem has no "", so that's causing the problem.
Try changing this line:
<%= #links.present? ? render("result") : Your url have a problem %>
to:
<%= #links.present? ? render("result") : "Your url have a problem" %>
I have established a connection to Active Directory through ldap/net. I am trying to pull AD attributes and values.
If I use the following code (using values.inspect) the query works.
<% #temp_search.each do |user| %>
TS = <%= user.sn %> <br>
<% user.each do |attribute, values| %>
<%= attribute %> <br>
<% values.each do |value| %>
<%= value.inspect %><br>
<% end %>
<hr style="border-color: red">
<% end %>
<% end %>
The portion of my controller doing the ldap query is s
filter = Net::LDAP::Filter.eq( "sn", "mendla" )
treebase = "dc=ccttapes1,dc=com"
#temp_search = ldap.search( :base => treebase, :filter => filter )
p ldap.get_operation_result
What I can't seem to get to is to just get the value for one particular attribute - for example, givenname.
I see results such as
cn
"Chris G. Mendla"
sn
"Mendla"
description
"Test account 1 for rails apps - DO NOT CHANGE PW"
givenname
"Chris"
initials
"G"
distinguishedname
"CN=Chris G. Mendla,OU=Users CCT,DC=CCTTAPES1,DC=com"
However, if I change <%= value.inspect %><br> to <%= value.givenname %><br> I get an error of
NoMethodError in Observations#index
Showing C:/Users/cmendla/RubymineProjects/employee_observations/app/views/observations/index.html.erb where line #61 raised:
undefined method `givenname' for "CN=Christopher Mendla,OU=Users CCT,DC=CCTTAPES1,DC=com":Net::BER::BerIdentifiedString
Rails.root: C:/Users/cmendla/RubymineProjects/employee_observations
Application Trace | Framework Trace | Full Trace
app/views/observations/index.html.erb:61:in `block (3 levels) in _app_views_observations_index_html_erb__474218211_78240600'
app/views/observations/index.html.erb:60:in `each'
app/views/observations/index.html.erb:60:in `block (2 levels) in _app_views_observations_index_html_erb__474218211_78240600'
app/views/observations/index.html.erb:58:in `block in _app_views_observations_index_html_erb__474218211_78240600'
app/views/observations/index.html.erb:56:in `each'
app/views/observations/index.html.erb:56:in `_app_views_observations_index_html_erb__474218211_78240600'
and if I try ``<%= givenname.value %>` I get
NameError in Observations#index
Showing C:/Users/cmendla/RubymineProjects/employee_observations/app/views/observations/index.html.erb where line #61 raised:
undefined local variable or method `givenname' for #<#<Class:0x9cd0230>:0x9fadaf0>
Rails.root: C:/Users/cmendla/RubymineProjects/employee_observations
Application Trace | Framework Trace | Full Trace
app/views/observations/index.html.erb:61:in `block (3 levels) in _app_views_observations_index_html_erb__474218211_83715540'
app/views/observations/index.html.erb:60:in `each'
app/views/observations/index.html.erb:60:in `block (2 levels) in _app_views_observations_index_html_erb__474218211_83715540'
app/views/observations/index.html.erb:58:in `block in _app_views_observations_index_html_erb__474218211_83715540'
app/views/observations/index.html.erb:56:in `each'
app/views/observations/index.html.erb:56:in `_app_views_observations_index_html_erb__474218211_83715540'
Request
My goal is to be able to search for an AD record by first and last names and then pull values for attributes such as mail or memberof.
(I am using ldap-net
In your example #temp_search should be an array of users that meet your search criteria. Each one of those users is a Net::LDAP::Entry object. On those objects you can call methods are available corresponding to the users attributes.
If only one user is returned, the Net::LDAP::Entry object will still be inside an array. In that case you could call something like:
#temp_search.first.cn
You can also call:
#temp_search.first.attribute_names to see all available attributes for that object.
For example, you could do something like:
<% #temp_search.each do |user| %>
#call user attributes
user.cn
user.memberof
#etc, other attributes
<% end %>
I have deployed my app for first time. Cap deploy was successful. However I was getting an error on a specific code segment. So I decided to delete this code segment and get the website up and running first before fixing this error.
I run cap deploy again but I am still getting the same error on the code segment that I removed from the source file (I see the error by tailing production.log). It was not suppose to be there. I searched around on the net and found that the problem is that there is a cached version of the app. I found out that a solution would be to delete the cache-copy folder in /shared folder.
I restarted my services (nginx, unicorn) and open the site again and I still get the same error on the code segment I removed.
I checked my new current folder, cached-copy folder and last release folder and all don't have the code segment that produces the error.
It's really odd to me. Any clue whats going on?
Thanks!
Code segment that produces the error:
ActionView::Template::Error (undefined method `stripe' for #<Rails::Application::Configuration:0x00000002a85578>):
20: <meta name="viewport" content="width=device-width">
21: <%= javascript_include_tag 'application' %>
22: <%= javascript_include_tag "https://js.stripe.com/v1/", type: 'text/javascript' %>
23: <%= javascript_tag "Stripe.publishableKey = '#{Rails.configuration.stripe[:publishable_key]}';", type: 'text/javascript' %>
24: <%= csrf_meta_tag %>
25: <%= stylesheet_link_tag "application", :media => "all" %>
26: <script type="text/javascript" src="//use.typekit.net/xoh2pss.js"></script>
app/views/layouts/application.html.erb:23:in `_app_views_layouts_application_html_erb__486989174473553269_34754060'
The line 23 was removed but its still shown as generating the error.
# config/initializers/stripe.rb
Stripe::API_KEY = 'asd8df9sadf766'
# application.html.erb
<%= javascript_tag do -%>
Stripe.publishableKey = <%= Stripe::API_KEY %>;
<% end -%>
Are your assets precompiled and the old all.js (or similar) being redeployed without this change present? If the routine invoked by the javascript portion isn't present that could produce an error -- that might be the stripe method you're trying to invoke. If they were manually precompiled and you made the change but didn't re-compile it, the redeploy would simply put the old one back out there.
I have output something like this:
#<Hashie::Mash created_time="1366008641"
from=#<Hashie::Mash full_name="Cor Valen" id="22340" username="_corin">
id="4344344286" text="Look Who It Is, My Brother, My Favorite Deputy">
This was an output if I did this:
<%= media.caption %>
I wanted to get the text part, and I did this:
<%= media.caption.text %>
gets me error: undefined method `text' for nil:NilClass
<%= media.caption[:text] %>
gets me error: undefined method `[]' for nil:NilClass
I don't get it?
Thanks
I had this problem with Instagram feeds, and I found that certain media items did not have a caption, so threw the error.
I solved this using:
<% unless media.caption.blank? %>
<%= media.caption.text %>
<% end %>
I assume media is this object. What's the caption? I don't see any param like this in your object, so why do you assume it exists? It's pretty obvious, it throws undefined method '[...]' for nil:NilClass, since your attribute does NOT exist.
You're probably looking for media.from.text, not media.caption.text.
I copied the JSON from the link you gave and ran it through irb, please see the output:
irb(main):004:0> media = Hashie::Mash.new(JSON.parse(File.open("inst.json").read))
=> #<Hashie::Mash data=[#<Hashie::Mash caption=#<Hashie::Mash created_time="1296656006" from=#<Hashie::Mash full_name="" id="1127272" type="user" username="cocomiin"> id="26329105" text="This is dummy text."> comments=#<Hashie::Mash> created_time="1296655883" filter="Gotham" id="22518783" images=#<Hashie::Mash low_resolution=#<Hashie::Mash height=306 url="http://distillery.s3.amazonaws.com/media/2011/02/01/34d027f155204a1f98dde38649a752ad_6.jpg" width=306> standard_resolution=#<Hashie::Mash height=612 url="http://distillery.s3.amazonaws.com/media/2011/02/01/34d027f155204a1f98dde38649a752ad_7.jpg" width=612> thumbnail=#<Hashie::Mash height=150 url="http://distillery.s3.amazonaws.com/media/2011/02/01/34d027f155204a1f98dde38649a752ad_5.jpg" width=150>> likes=#<Hashie::Mash count=35 data=[#<Hashie::Mash full_name="Kevin S" id="4" profile_picture="" username="mikeyk">, #<Hashie::Mash>]> link="http://instagr.am/p/BV5v_/" location=nil tags=[] type="image" user=#<Hashie::Mash full_name="Cocomiin" id="1127272" profile_picture="http://distillery.s3.amazonaws.com/profiles/profile_1127272_75sq_1296145633.jpg" username="cocomiin">>]>
irb(main):005:0> media = media.data[0]
=> #<Hashie::Mash caption=#<Hashie::Mash created_time="1296656006" from=#<Hashie::Mash full_name="" id="1127272" type="user" username="cocomiin"> id="26329105" text="This is dummy text."> comments=#<Hashie::Mash> created_time="1296655883" filter="Gotham" id="22518783" images=#<Hashie::Mash low_resolution=#<Hashie::Mash height=306 url="http://distillery.s3.amazonaws.com/media/2011/02/01/34d027f155204a1f98dde38649a752ad_6.jpg" width=306> standard_resolution=#<Hashie::Mash height=612 url="http://distillery.s3.amazonaws.com/media/2011/02/01/34d027f155204a1f98dde38649a752ad_7.jpg" width=612> thumbnail=#<Hashie::Mash height=150 url="http://distillery.s3.amazonaws.com/media/2011/02/01/34d027f155204a1f98dde38649a752ad_5.jpg" width=150>> likes=#<Hashie::Mash count=35 data=[#<Hashie::Mash full_name="Kevin S" id="4" profile_picture="" username="mikeyk">, #<Hashie::Mash>]> link="http://instagr.am/p/BV5v_/" location=nil tags=[] type="image" user=#<Hashie::Mash full_name="Cocomiin" id="1127272" profile_picture="http://distillery.s3.amazonaws.com/profiles/profile_1127272_75sq_1296145633.jpg" username="cocomiin">>
irb(main):006:0> media.caption.text
=> "This is dummy text."
I was looking into How to use rails-i18n with HAML to find out how i18n works together with haml but ran into an issue I can't figure out.
This works:
en.yml
en:
sitename: "Happy Sunday"
new.haml
%h1= t("sitename")
When I change the yml to
en.yml
en:
home:
sitename: "Happy Sunday"
new.haml
%h1= t("home.sitename")
Then I get the following error:
ArgumentError in Devise/sessions#new
Showing
..../devise/sessions/new.html.haml where line #20 raised:
syntax error on line 4, col 6: ` home:'
Extracted source (around line #20):
17: = flash[:alert]
18: .row
19: .headline.pagination-centered
20: %h1= t("home.sitename")
21: %h2= t("slogan")
22: .row.headline.pagination-centered
23: %a{:href => "/tour"}
The message:
syntax error on line 4, col 6: ` home:'
suggests an error in your Yaml. Check en.yml, especially that you’re not using tabs and that your indentation is consistent.