Herkou class changes not detected - ruby-on-rails

I'm using Herkou for some Rails 3 hosting. I have pushed code to Heroku, and I am getting the following error from the logs:
NoMethodError (undefined method `format_date' for #<Project:0x00000001938f40>):
This method does exist! I can for example so this:
$heroku console
>> Project.format_date('2011-07-07 10:50')
=> "2011-07-07"
So my code appears to be deployed. Project responds to format_date.
I also tried heroku restart with no success.
Can anyone help me? Any and all suggestions are appreciated!

Are you sure you are calling format_date on the class itself, like you do in your example, and not on an instance of the class? I.e. Project.new.format_date("2011-07-07 10:50")

Related

Need help diagnosing a 500 error in Heroku

I built a webapp for a class that uses a weather API to display the local weather on a single page. I've uploaded the app to Heroku, but when I try to view the page, I get a 500 error. I've looked at the logs, but I can't decipher what is going wrong exactly. Can someone please take a look at the logs and point out what's going wrong?
Here is a link to the logs: https://gist.github.com/allredbm/70daea5a4c372c644cac
The error is as follows:
app/controllers/home_controller.rb:18:in `index'
NoMethodError (undefined method `[]' for nil:NilClass)
On line 18 of your home_controller (index action), you're referencing a variable with a []. The variable isn't defined.
You need to make sure the variable is defined before trying to reference it.
You can view the whole backtrace by doing either:
Set config.consider_all_requests_local = true in config/environments/production.rb - this is the quickest
Add New Relic (free), configure it, reproduce the 500, wait 1 minute and go into the errors tab in New Relic - this is the preferred as you don't expose the error to the public

Conflict between Rails Admin and Impressionist gems

I'm using the latest version of the Impressionist and Rails Admin gems, and wondering if anyone could shed some light on an annoying conflict I'm experiencing. The problem is roughly documented here - https://github.com/sferik/rails_admin/issues/1315, yet the vaguely described solution is not working for me. When I have the line is_impressionable in my Listing model, I get an error when starting my Rails server with rails s:
...rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined local variable or method `is_impressionable' for Listing(no database connection):Class (NameError)
If I first start the server, and then add the 'is_impressionable' line, everything works fine, so the problem only occurs during initialization. I don't fully understand the initialization process, so am not sure how to go about getting this to work.
I have tried moving all my rails_admin model configuration options to their respective models, rather than in the initializer, which had no effect. I also have the following line in my initializer:
config.included_models = [Listing,ListingImage,AllOtherModelsHere...]
I have tried adding single quotes around these model names, which results in the following errors, as described in the github issue here
[RailsAdmin] Could not load model Listing, assuming model is non existing. (undefined local variable or method `is_impressionable' for Listing(no database connection):Class)
Any ideas what else I can try to make these gems work together? I don't want to have to remove the is_impressionable line every time I want to restart the server or generate a migration...
Not sure if the same issue that I had but yet I will post what worked for me just in case someone struggles with this too:
Im on a ruby 2.1.5 project with rails 4.2.0 and among other gems I'm using rails admin.
I run into several weird problems trying to set this up. For instance if I added the is_impressionable call within one of my models for some reason the execution of that file stopped there and I started getting weird errors like any method declared below the is_impressionable failed with undefined error.
So what I end up doing was:
class MyModel < ActiveRecord::Base
include Impressionist::IsImpressionable
is_impressionable
end
So this solved my issue and now i can access #my_model_instance.impression_count as expected.
I changed every occurrence of Klass to 'Klass'.constantize in initializer.

undefined method `delay' for UserMailer:Class

I am getting the following error while writing mail notification process asynchronously by using delay method.
NoMethodError in SampleController#create
undefined method `delay' for UserMailer:Class
I have the following code in my controller.
UserMailer.delay.idea_author_notification(self,nfication)
I have already installed delayed_job gem also started delayed_job by using jobs:work rake task.
Shall I need to do some other changes for using delay method for executing mail related code in background ?
Please help me on this asap..
Thanks in advanced...
the method delay is not existed for any action mailer class. So you can not call that method for the UserMailer:Class.
For that you can check all the methods for the mailer class in the rails console. i.e
UserMailer.methods
and to check particular method existed or not, run the following line.
UserMailer.methods.include?(:delay)
The above line returns false
OR
if you want to use delayed jobs, please go through the following link in github. It would definitely help you.
delayed_jobs_for_rails2.x.x

NoMethodError: undefined method 'index' when calling deliver on rails 3.1 mailer

I have set up a staging instance of a rails 3.1 application on Heroku and everything seems to work fine except I'm getting a strange error when I try to send emails. I am using the sendgrid starter addon for email delivery. The full error is below:
NoMethodError: undefined method `index' for #<Mail::Message:0x000000048daf28>
/app/.bundle/gems/ruby/1.9.1/gems/mail-2.3.0/lib/mail/message.rb:1289:in `method_missing'
/app/.bundle/gems/ruby/1.9.1/gems/mail-2.3.0/lib/mail/encodings.rb:117:in `value_decode'
/app/.bundle/gems/ruby/1.9.1/gems/mail-2.3.0/lib/mail/encodings.rb:101:in `decode_encode'
/app/.bundle/gems/ruby/1.9.1/gems/mail-2.3.0/lib/mail/fields/unstructured_field.rb:74:in `do_decode'
if I just generate the message object without calling deliver on it and inspect it everything seems fine. I am not seeing this error on my production app. Can you tell me what this error means and how to resolve it? Thanks.
Got the same error on my local machine using Rails 3.0.11. It happened after I passed some object instead of a string to the mail :to attribute. So be sure that the :to attribute is a string!
mail(to: object.to_s)
A new version of Mail, Mail 2.4.0, was released this weekend. I would recommend upgrading to this latest version and seeing if that has fixed your issue.
This error was the result of using Class instead of Module when defining a mail helper I'd created.
This error happened because I was setting custom headers to an integer value. Using to_s on these values resolved the issue for me.
I had a similar problem. However, the error I received was:
NoMethodError (undefined method `ascii_only?' for nil:NilClass)
My problem was I had:
mail(to: emails,....)
And my variable "emails" was actually an array, instead of being one single string of emails.

FriendlyId: undefined method `use_slug?' for nil:NilClass

I am creating a new environment besides production. I copied all the configurations from my production environment, changing what needed to be changed.
As it is the servers do start, but when I do a query I get this exception:
NoMethodError (undefined method `use_slug?' for nil:NilClass):
vendor/gems/friendly_id-2.3.4/lib/friendly_id/active_record2/finders.rb:65:in `slugged?'
vendor/gems/friendly_id-2.3.4/lib/friendly_id/active_record2/finders.rb:43:in `finder_class'
vendor/gems/friendly_id-2.3.4/lib/friendly_id/active_record2/finders.rb:37:in `finder'
vendor/gems/friendly_id-2.3.4/lib/friendly_id/active_record2/finders.rb:32:in `method_missing'
vendor/gems/friendly_id-2.3.4/lib/friendly_id/active_record2/slugged_model.rb:149:in `find_one'
app/controllers/home_controller.rb:5:in `index'
The line in question does this:
#page = Page.find("home")
I am using FriendlyId 2.3.4, and Rails 2.3.4. The code is the same for the production environment, and it's working just fine there, so I'm not really sure on what's going on here...I could see that the line where the exception gets raised does
friendly_id_config.use_slug?
so for a reason I'm not aware of friendly_id_config is nil.
Thanks for any guidance on this problem
I found a workaround to this issue by loading the server using the production environment.
I was trying to use a 'preprod environment, and somehow FriendlyId didn't like that strange environment.
Load the app using RAILS_ENV=production and it worked fine.
Not a solution, but at least could move on...

Resources