Reputation: 1923
Solved: the issue was from Lob's internal server error on their end.
I'm going through the following example taken from this blog on Lob, and the code can be found on Github here
After I cloned the repo, I bundle installed
the gems, fired up the server, and head towards localhost:3000/postcards
. After inputting a short message in the Message field, I am redirected to an error page with the undefined method `first' for nil:NilClass error.
The error appears to be in the controller
class PostcardsController < ApplicationController
LOB = Lob.load(api_key: "test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc")
def index
end
def create
template_file = ERB.new(File.open(File.join(Rails.root, 'app', 'views', 'postcards', 'postcard_front.html.erb')).read)
custom_html = template_file.result(binding)
@results = LOB.postcards.create(
name: "Demo Postcard",
to: {
name: params[:postcards][:to_name],
address_line1: params[:postcards][:to_address_line1],
city: params[:postcards][:to_city],
state: params[:postcards][:to_state],
zip: params[:postcards][:to_zip],
country: "US",
},
from: {
name: params[:postcards][:from_name],
address_line1: params[:postcards][:from_address_line1],
city: params[:postcards][:from_city],
state: params[:postcards][:from_state],
zip: params[:postcards][:from_zip],
country: "US",
},
front: custom_html,
message: params[:postcards][:message],
full_bleed: 1
)
end
end
From the tutorial blog, it appears that this error should not be happening. What is this error, and why is it happening on my environment?
Upvotes: 0
Views: 338
Reputation:
There is an open issue on this at GitHUb. I am getting the same error. 7/27/2016
Upvotes: 1