Docpad error 'length' of undefined - undefined

My config
After "docpad run" produces errors
What could be the problem?
I tried to remove "docpad-paged", but don't result.

I see that getPageUrl is complaining that there is not a post for the Id -1 here
You need to change this line
to
<% for pageNumber in [0..#document.page.count-1] by 1: %>
the change here is by 1 as it will prevent coffee-script automatically going from 0 to -1 when there are no pages to loop.

Related

Why Do I Get Function Errors In My Script?

I watched a YouTube video on how to make a donate button in Roblox and followed the steps. But then when I used it, it gave me multiple errors.
I have tried changing .connect to :Connect but it gave me more errors, I tried changing end) to end, but it gave me more errors.
Code:
local id = 459818680
script.Parent.TextButton.MouseButton1Click.connect()(function()
game:GetService("MarketplaceService"):PromptProductPurchase
(game.Players.LocalPlayer, id)
end)
I expected to be able to click on it when I tested it and a menu for a purchase would pop up. Nothing happened. I also got errors like this:
Players.ImNotKevPlayz.PlayerGui.ScreenGui.LocalScript:4: bad argument #1 to 'connect' (RBXScriptSignal expected, got no value)
When I tried the debug command in Roblox commands, it gave me this error:
Error in script: '=' expected near ''
Heyo, your script almost works, it just looks like you've just got some syntax errors.
bad argument #1 to 'connect' (RBXScriptSignal expected, got no value)
This means that the MouseButton1:Connect function was expecting an argument, but you didn't give it anything.
Try out this fix :
local id = 459818680
local targetButton = script.Parent.TextButton
local MarketplaceService = game:GetService("MarketplaceService")
targetButton.MouseButton1Click:Connect(function() -- <-- this just needed to be fixed
local player = game.Players.LocalPlayer
MarketplaceService:PromptProductPurchase(player, id)
end)

Ruby + DBI + MySQL: undefined method `to_ary' for nil:NilClass (NoMethodError)

I am trying to connect to MySQL suing DBI. I am following Using the Ruby DBI Module documentation.
Here is my code:
require 'dbi'
begin
dbh = DBI.connect("DBI:Mysql:<db_name>:<mysql_hostname>", "<mysql_user>", "<mysql_password>")
row = dbh.select_one("SELECT VERSION()")
puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts "Something went wrong connecting the database"
puts e.errstr
end
sth = dbh.prepare("SHOW TABLES")
sth.execute
while row = sth.fetch
puts row
end
sth.finish
dbh.disconnect
This code fails with below error:
Server version: 5.6.13-log
/home/user/dbi_testing.rb:14:in `puts': undefined method `to_ary' for nil:NilClass (NoMethodError)
In above error, I am printing the MySQL version (Server version: 5.6.13-log) just to ensure that I have good working connection to the DB.
This error is thrown by the while loop above. So I changed it to below:
sth.fetch do |row|
puts row
end
And still get the exact same error.
So it means either sth.fetch method does not exists or something is wrong with the way I am accessing it.
Could you help me resolving this error.
UPDATE: I made some progress, if I put it as below, the I can see the tables:
sth.fetch_hash do |row|
puts row
end
The output is:
Server version: 5.6.13-log
{"Tables_in_mstrmd"=>"DSSCSADDRESS"}
{"Tables_in_mstrmd"=>"DSSCSBADGETB"}
{"Tables_in_mstrmd"=>"DSSCSCONTACT"}
{"Tables_in_mstrmd"=>"DSSCSDEVCKEY"}
{"Tables_in_mstrmd"=>"DSSCSPSNLZTN"}
{"Tables_in_mstrmd"=>"DSSCSRCOLCON"}
{"Tables_in_mstrmd"=>"DSSCSRINSTRG"}
{"Tables_in_mstrmd"=>"DSSCSSUBINST"}
{"Tables_in_mstrmd"=>"DSSCSSYSPROP"}
{"Tables_in_mstrmd"=>"DSSMDJRNINFO"}
{"Tables_in_mstrmd"=>"DSSMDJRNLNKS"}
{"Tables_in_mstrmd"=>"DSSMDJRNOBJC"}
{"Tables_in_mstrmd"=>"DSSMDJRNOBJD"}
{"Tables_in_mstrmd"=>"DSSMDJRNOBJS"}
{"Tables_in_mstrmd"=>"DSSMDLNKITEM"}
{"Tables_in_mstrmd"=>"DSSMDLNKPROP"}
{"Tables_in_mstrmd"=>"DSSMDOBJBLOB"}
{"Tables_in_mstrmd"=>"DSSMDOBJCMNT"}
{"Tables_in_mstrmd"=>"DSSMDOBJDEF2"}
{"Tables_in_mstrmd"=>"DSSMDOBJDEFN"}
{"Tables_in_mstrmd"=>"DSSMDOBJDEPN"}
{"Tables_in_mstrmd"=>"DSSMDOBJINFO"}
{"Tables_in_mstrmd"=>"DSSMDOBJLOCK"}
{"Tables_in_mstrmd"=>"DSSMDOBJPROP"}
{"Tables_in_mstrmd"=>"DSSMDOBJSECU"}
{"Tables_in_mstrmd"=>"DSSMDOBJTRNS"}
{"Tables_in_mstrmd"=>"DSSMDSYSPROP"}
{"Tables_in_mstrmd"=>"DSSMDUSRACCT"}
So, I am able to see the tables when I use sth.fetch_hash. Then what is wrong with sth.fetch?
Any pointers would be of immense help.
UPDATE (WORKAROUND):
I ran puts sth.methods.sort and here is the output:
fetch
fetch_all
fetch_array
fetch_hash
fetch_many
fetch_scroll
fetchable?
I changed sth.fetch to sth.fetch_array and now I am able to see the tables Fine.
The credit goes to a this comment by #philant
So, in a way my question has got a workaround.
But I still want to know why the method sth.fetch did not work ? Any explanation would be really helpful.

Coldfusion case generating an error

I am trying to troubleshoot a problem with our Coldfusion application.
The problem is this line I think-:
<cfset discountAmountClause =
"CASE WHEN discountAmount_rateType = 0 THEN #oldPrice# * discountAmount_discount / 100
ELSE discountAmount_discount END">
The error message from the application is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* discountAmount_discount / 100 ELSE discountAmount_discount END
I'm not sure whether there is an issue with the code or something more serious so if anyone with more experience than me can shed some light I would be really grateful...
Your oldPrice variable has Null or blank value and that is causing your sql to misfire.
You can adjust it conditionally:
<cfif oldPrice EQ "">
<cfset oldPrice = 0>
</cfif>
<cfset discountAmountClause = "CASE WHEN discountAmount_rateType = 0
THEN #oldPrice# * discountAmount_discount / 100
ELSE discountAmount_discount
END">
So after further investigation and thanks to the help of the comments left in this thread I managed to track down the error to the #oldprice# variable.
One of our pages that called the #oldprice# variable shouldn't have been active because the #oldprice# just didn't exist for that page. A link to this page was included on a number of other pages along with the #oldprice# variable which then caused a bunch of pages to 404 error.
Once I removed the problem page the other pages worked fine and the error stopped being generated.
It was a little harder to track this down as this page was one of 1679! However with the assistance given here I managed to get there in the end.
Thanks!

Getting random nil.each error in mysql2 gem when using :include in Rails's find

I'm randomly (as it seems) getting a nil.each error on my localhost. Was feeling pretty confident in the code though so I pushed it to heroku and it works fine there.
Here's my view code:
<h2><%=#book.name.upcase%></h2>
<br />
<% #book.chapters.each do |chapter| %>
<h3>Chapter <%=chapter.number%></h3>
<% chapter.verses.each do |verse| %>
<b><%=verse.number%>)</b> <%=verse.body%>
<% end %>
<br /><br />
<% end %>
At first all I had in my controller was something like #book = Book.find(params[:id]) and that worked fine except for the speed. Then I changed to this:
def show
if params[:book_name]
##book = Book.find_by_sql(["select * from books where UPPER(name) = UPPER(?)", params[:book_name]]).first
#book = Book.where(["UPPER(name) = UPPER(?)", params[:book_name]]).includes(:chapters => :verses).first
raise ActiveRecord::RecordNotFound, "Page not found" if #book.nil?
elsif params[:id]
#book = Book.find(params[:id].to_i, :include => {:chapters => :verses})
end
end
Now I randomly get this error:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
...
app/controllers/books_controller.rb:14:in `show'
One difference is heroku uses postgre and I'm using mysql.
Heroku url: http://kjv-on-rails.heroku.com/books/1
Full application code: https://github.com/tybro0103/KJV-on-Rails
Update
I just checked the Full Trace and realized the error occurs here:
mysql2 (0.2.6)
lib/active_record/connection_adapters/mysql2_adapter.rb:635:in
`select'
So the error is happening in the mysql2 gem.
Note
It's been brought to my attention that I have odd/redundant relations & data. I realize this, I promise! I don't believe that's causing the error though. :)
Note
By random here's what I mean... On some books I never see this error. On others I see 90% of the time, while yet on others I see it 50% of the time. I just hit refresh over and over and sometimes it works and sometimes it doesn't. I guess the only way to really see what I mean is to download the code yourself. My guess is no one will which means I'll start a bounty in a couple days as an incentive. :)
UPDATE
So the error occurs in the mysql2 adapter. Funny thing is that #book = Book.find(params[:id].to_i, :include => {:chapters => :verses}) causes the error when running rails server. In the rails console I can run the same command all day long and it works fine. It was using webrick, but I tried switching to mongrel and got the same error. I've also tried switching from ruby 1.8.7 to 1.9.2 and get the same error. It seems like maybe there is some sort of memory limit within the rails server maybe?
AHHHH... I found the trouble maker! I just downgraded mysql from 5.5 to 5.1 ...problem gone! What a pain in the #$$ that was.
It still would be nice to be able to use the latest release of mysql however. If someone can find a way to make it work using mysql 5.5 I'll mark that as the accepted answer.

SubSonic 3.0.0.3 Update Exception

When I attempt to update in SubSonic I'm greeted with a Null Reference Exception.
This is the exception message I get:
Object reference not set to an instance of an object.","StackTrace":" at SubSonic.Query.Update.GetCommand()
I've checked the object I'm updating and there are no missing fields, all the class properties match the database column names.
Any Ideas what this could be?
Cheers Tony
Apparently this is an issue already found. I've followed what the OP of the issue stated and it works fine.
This is how to fix it for the time being:
Go to : http://github.com/subsonic/SubSonic-3.0/tree/master , then click on download and select 3.0.0.3.
In Subsonic.Core/Query/Update.cs go to the "GetCommand" method (line 244)
Change x => x.Name.Equals
for this
x => x.QualifiedName.Equals
Compile it and your sorted.