methods,undefined , Repeating Error: undefined method `start_with?' for nil:NilClass

Repeating Error: undefined method `start_with?' for nil:NilClass


Tag: methods,undefined

I've gotten this weird error message that keeps me from working on my application.

undefined method `start_with?' for nil:NilClass

with line 5 highlighted in my app/views/layouts/application.html.erb file:

<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>

The error seems to come out of nowhere. The first time I got it I had attempted to load CarrierWave. I got through ReadMe but it didn't work so I tried to back out of the installation.

When I comment out this line the app loads but with no bootstrap formatting at all. I initially focused my search with CarrierWave, deleted and re-installed the gem, but was unsuccessful and found nothing really pointing me in the right direction. I spent days on this. Finally, I reached out to a mentor who pulled my code down from github and found no errors. The app worked fine for him. I pulled down a previous, known working commit, and it worked for me as well. So, although not solved I could continue working on my app (having to re-do some work). Now, the problem has reappeared while working on my app. Not CarrierWave this time, just normal editing. Without warning the application just stopped loading but with the same start_with? error message on my app/views/layouts/application.html.erb file.

I've spent a considerable amount of time searching for answers and a permanent fix on Stackoverflow.

Solutions that seemed to work for others, but HAVE NOT worked for me are: 1. Remove //= require_tree . from application.js, and 2. Downloading and installing node.js

Some posts support the thought that the idea that the issue is local and would only show up in dev, not prod. I'm only working in dev at the moment. While there's a lot of other info, I've struggled with this for days now and feel that every possible solution gets me further down a rabbit hole that is completely foreign to me. I am a newbie...about 3 months into my knowledge on Ruby. I'm really not even sure what code to add here because I can't seem to isolate the issue. I only know that formatting seems to be affected when I comment out line 5 (as above).

Trust me when I say I've searched quite a bit. I'm very hard headed, but optimistic I can find an answer if given the time but I'm stumped here and just want to move on with learning to create with Ruby/Rails.

My gem file is below. Perhaps I'm missing something very obvious.

ruby '2.2.0'

source ''

group :production do
  gem 'pg'
  gem 'rails_12factor'

gem 'font-awesome-sass'
gem 'bootstrap-sass'
gem 'simple_form'

gem 'devise'

gem 'seed_dump'

gem 'rails', '4.2.0'
group :development do
  gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
 gem 'byebug'
 gem 'web-console', '~> 2.0'
 gem 'spring'


//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap-sprockets

The only other info I can provide is that I've scaffolded my resources and used devise to create my User model.

Thanks. I'm in your debt if you can help me solve this. I am new, but I want to learn.


I came across this same issue myself maybe my solution will help you out. Check your /app/assets/stylesheets/application.scss file for "bootstrap-spockets". Commenting this out solved it for me.


Get warning when convert double to NSDecimalNumber

I'm trying to convert a double to an NSDeciamlNumber. Here is my code: - (NSDecimalNumber *)myMethod { double amount = 42; ... return [NSDecimalNumber numberWithDouble:amount]; // Get warning here } But I get the following warning: Incompatible pointer types returning 'NSNumber *' from a function with result type 'NSDecimalNumber *'...

Having issues with methods

Alright, I have a class assignment to create 3 predetermined methods for a rock, paper, scissors program written by the teacher. However, when I run the program it running the methods multiple times in a row. I've looked through the code several times and can't figure out the problem. Below...

In JavaScript, is there any difference between typeof x == 'y' and typeof x === 'y'?

I'm aware of the difference between strict and loose comparison operators. Clearly x == y is different from x === y. But whenever I see code that uses typeof, it always uses ===. If the typeof operator always evaluates to a string (such as 'boolean', 'number', etc.), then wouldn't typeof...

Can inherited method access subclass fields in Java

I'm having trouble understanding inheritance. In the code below, why doesn't the inherited method access the field in the subclass? Is there any way to access the subclass field without overriding the inherited method? class Fish { private String fishType = "Fish"; public String getFishType() { return fishType; } }...

Discover all PSmethods of an object

When I run this command: $psise.CurrentPowerShellTab.AddOnsMenu.SubMenus | GM The result does not show me the methods Remove & Removeat which I know do exist. So how do we discover all the methods available to an object? I have run GM -force but still don't see the Remove methods. Are these...

Can't understand this Javascript function (function overloading)

I'm reading Secrets of Javascript Ninja and came across an example that I cannot fully understand. This same example was cited by some other user here before, but their doubts are different than mine. Here is the example: function addMethod(object, name, fn) { var old = object[name]; object[name] = function(){...

Why can't I call a method I define in a field? [duplicate]

This question already has an answer here: Calling newly defined method from anonymous class 5 answers Consider the following code. public class B { void foo() { System.out.println("foo"); } } public class A { B b = new B() { void lorem() { System.out.println("Lorem"); } }; void...

How to link code for button function to checkboxlist in C#?

I would like to link the function of my Chart Output Button to the items in my check box list such that when an item in the check box is selected or deselected, the page is reloaded again and my chart is refreshed. My codes to refresh the chart have...

Assigning a variable from another class

I have a UIView with a UIButton created in 1 class: "viewClass". In my mainVC class, I called viewClas and I needed to call a method in mainVc when the button is selected, so I created a protocol. (I hope that was clear.) Here's how I set up the protocol...

How to handle empty parameters in a main method java call

I would like to have a dynamic way of passing in parameters to a java main method call which is done via the Command Line(cmd) to a Runnable JAR file. At the moment my main() method takes 6 parameters and sets each one to a variable before calling another method...

Java: Shuffle a Deck of 32 cards?

I've wrote this method on my own I want to know if there is a better way to do it? public Card[] Shuffle(){ for(int i = 0; i < Deck.length; i++){ int x = i + (int) (Math.random() * (32 - i)); Card temp = Deck[i]; Deck[i] = Deck[x]; Deck[x]...

Return out of method instead of returning anything or null [on hold]

public static string DecryptString(string EncryptedString) { try { ....... .... } catch { return something else if decryption fails instead of null or empty string; } } I am trying to return error if the decryption fails not the string....

Calling “Form” class method from “A” class without adding a reference to the “Form” class

I have two Projects one is a Winform application another is a Class library. I have added a reference to the class Library in Winform and called a method of the class library. Now I want to call a different method in winform application from class library but I can't...

how to post parameter like {“register_id”:“3”} in AFNetwroking

i Tried it but didn't work in AFNetworking only showing parameters error but i used postman to check and when i send data via key and value it showing error but from raw data i send {"register_id":"3"} then it will show me data so how to post parameter like this...

Schedule to run a method at periodic time in java

I have to schedule a method to be executed when starting and periodically thereafter at intervals of 1 minute. For that I have done this: public void init(){ loadConfig(); //method which needs to be executed periodically Timer scheduler = new Timer(); scheduler.scheduleAtFixedRate(loadConfig(),60000,60000); } This is giving an error and it...

Run class methods in different threads

Let's suppose I have this class: public class Myclass { method1(); method2(); method3(); } I want to know if there's a way to run all 3 methods in different threads simultaneously. Is there a way to create a class MyThread : public class MyThread{ //implementation } in way that it...

wrapMethod Meteor methods

I was looking into this presentaton, builindg large meteor applications, and i like the idea of the wrapMethod(), but it seems like i cant use it like on the example. Here is my code. Meteor.methods({ 'EX.Accounts.Methods.updateProfileData' : function(userId, firstName, secondName) { check([firstName, secondName], [String]); Meteor.users.update(userId, { $set: { 'profile.firstName': firstName,...

Passing “this” as a Method Argument - Clarification

I am currently working on Java Swing lessons after finishing my first set of lessons in Java. In this lesson, we are working on communication between different components (buttons,toolbars,etc.) that we have been studying. The problem is, "this" is being passed as a method argument for the addActionListener() method. This...

Instance method returns correct array from one view controller but null from others

This is my first post so apologies for any errors I make, but this has been frustrating me for hours now and I cannot find a solution. I have an app that uses a UITabBarViewController that has 3 tabs: FirstViewController, SecondViewController and ThirdViewController. I have an NSObject class (Manager) where...

Calling an object and its method from another object class method

I have created some classes/objects for some animations. I created a class called Navigation(), and another class called Stars(). Each of the classes have their own methods and objects associated with them. I have created a method within the Navigation() class that attempts to run a method and the object...

Undefined local variable post

I write this code: <% @user.posts.each do |post| %> <%= render 'post', locals: { post: post, user: @user} %> <% end %> Then in _post.htm.erb I write follow code: <div class="post-title"> <img src="<%= @user.avatar.url%>" class="img-rounded post-image"> <h4 id="post-name"><%= @user.first_name + ' ' [email protected]_name %> </h4> <div id="post-date"><%= post.created_at.strftime('%d %b -...

java - How to retrieve anything inside method

From what i know, java cannot retrieve anything inside method. so i using option -g or -g:vars in javac. for e.g : class Test { int a=0; void method(boolean boo){ String b; try { new Thread().sleep(1000); } catch(InterruptedException e){} JOptionPane.showMessageDialog(null,"test"); BufferedImage File("C:\\file.png")); } } So, i use BCEL to...

if condition for multiple methods in a class

I'm writing in python to get a better feel for good practices when using classes. I've written a few methods for a couple classes; dog and person. I have introduced a new method for dog called die, defined below: def die(self): if self.owner: self.owner.pets.discard(self) self.owner = None self.dead = True...

JS: Is it possible “something(arg)” and “something.my_method(arg)” at same time

I know how create just a function something(arg) something = function(arg) { console.log('Function result', arg); } I know how create an object with function something.my_method(arg) something = { my_method: function(arg) { console.log('Method result', arg); } } Is it possible to write code, wher both something(arg) and something.my_method(arg) are exists? Like...

Javascript Calling a nested function from within itself

If I run the following... function outer(){ function inner(){ } inner(); } inner will run the first time as expected. If I then try to run the following... function outer(){ function inner(){ inner(); } inner(); } inner will again run the first time as expected, but then fails at any...

Using NON static class Methods Without reference

I'm new to Java. I know the concept of static and non static method. I'm wondering if it's possible to use non static methods of a class without having to create a reference to it. Like for example, for my program I'm working with Date objects, and I need to...

error about returning a string from a String method

Why am I getting an error in both of these methods that say 'this method must return type string...when I am returning type string. I am trying to do the stupid ninety-nine bottles of beer on the wall question that I'm sure everyone had learning java. But in my book...

Palindrome Check in Java using two Methods will not compile [closed]

I was working on this for a class assignment, and I cannot for the life of me get it to compile. I keep getting this error: error: reached end of file while parsing } ^ 1 error I have tried adding, removing, and checking all of my braces, but...

Meteor template helper not returning value

I wrote a method to return a value onto the client: Template.Cart.helpers({ cartPrice: function(result) {'returnCartPrice', function(error, result) { if(error) { alert(error.reason); } else { alert('result is ' + result); //this alerts return result; } alert('result is ' + result); //this does NOT alert return result; }); } }); cart.html:...

JFrame not including certain variables

I am new to using JFrame. I have a JFrame class that is separate from the main class. I have been having trouble getting it to work, like separating it from the main class. I have an issue though where a constructor in my JFrame class is not used, and...

Why don't I get any output?

I am trying to write my first OOP code in C++, but for some reason I am not getting any output. I am trying to create a class that contain a method getSquare() that accept an int n and returns the number squared. Can anyone tell me where I am...

Reference method from different class as curried function

There are two merge methods in RACSignal: - (RACSignal *)merge:(RACSignal *)signal; + (RACSignal *)merge:(id<NSFastEnumeration>)signals; When I write RACSignal.merge it references static method: class func merge(signals: NSFastEnumeration!) -> RACSignal! How to reference object method? I can't write self.merge, because it is in wrapper class and self is not RACSignal....

How can this be undefined in the constructor of an Angular config class?

I've found some examples online, where people create TypeScript config classes and pass them on to Angular. When I've tried it, I got the weird exception, that this was undefined. A closer look to the other implementations revealed, they only use the constructor, so, are those examples actually inherently wrong...

handle different instance variables in method

So if I have a method where a variable can be an instance of a bunch of different classes where only some of them have a specific instance variable, how do I use this instance variable in the method without getting the cannot be resolved or is not a field...

“Undefined method PDO::execute()” despite using prepare

This code has been working before, but I recently added a database class. I get the instance and connection from it: $connection = MYSQLDatabase::getInstance()->getConnection(); $connection->prepare("INSERT INTO users etc etc....... $insertArray = $connection->execute(array( ":username" => $_POST["username"] )); getInstance() returns the database instance. getConnection() returns the connection property which contains: new PDO('mysql:host='...

Why “if” is not doing anything in this boolean method?

import java.util.Scanner;//import Scanner public class review{ //name of the program public static void main(String[]args){ // main statement Scanner i=new Scanner(; System.out.println("Enter a string"); String b=i.nextLine(); System.out.println("Enter a letter"); char; System.out.println("Answer is "+test1(b,c)); } public static boolean test1(String a, char b){ boolean result= true; for(int i=0;i<a.length();i++) if(a.charAt(i)==b) result =true; else...

jquery $(this).attr('href') returns undefined

I've got a very simple code HTML <a class="qqPopupCTA" href="">Button</a> JS $qqPopupCTA = $('.qqPopupCTA'); function showForm(e){ e.preventDefault(); var targetPageUrl = $(this).attr('href'); // do stuff } $qqPopupCTA.on('click', function(e){showForm(e);}); However I keep getting undefined href. Console.log($(this)) returns "window" and console.dir($(this)) returns "e.fn.init[1]" Any idea what am I doing wrong? The code is...

Downcasting doesn't work and functions called from object own class instead of where the function is (Java)

i have this classes hierarchy: public class Musician { private String name; public String instrument; public Musician(String name, String instrument) { = name; this.instrument = instrument; } public String getName() { return name; } public String getInstrument() { return instrument; } private String getClassName() { return "Musician"; } public...

Invoke a custom method on a DOM element

I want to invoke a custom method on a DOM element like this : <div id="MyObject"> <!-- some elements --> </div> <script> function doSomething() { // do something with input DOM element } $("MyObject").doSomething(); </script> How can I develop this problem? Is it necessary to use jQuery or not?...

What is the correct way to use System.exit() method in java and call a method after? [closed]

How do I create an option in my program where the user can exit the program? For some reason, it won't let me exit it using System.exit(). I've debugged and found that the only problems with the program are with these lines: else if (input==6){ System.exit(); } else{ main(); }...

prepareForSegue (ViewController)

Then i try to sent data from one view to another override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "varView" { var viewController = segue.destinationViewController as ViewController var indexPath = self.tableView.indexPathForSelectedRow() viewController.varView = self.exams[indexPath.row] } } I get an error at witch says that ViewController is a undeclared?...

Why does my .data function work in pieChart but not in lineChart in dc.js?

I want to plot data for a dimension that's not in crossfilter so I'm forced to use .data. All is fine for a pieChart, but when I switch to a lineChar I get the error p is undefined (Firefox) or Cannot read property y of undefined (Chrome). I tried following...

What Is The Difference Between Passing Parameters By Output And By Reference In C#

I have been making an effort on C# methods. There are three ways that parameters can be passed to a C# methods. Value parameters : This method copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside...

C# Recursion Error - Extension Methods

I get an error here saying that the program could not exit the infinite loop. public static class Program { public static void Main(string[] args) { Object obj = new Object(); Console.WriteLine(obj.GetClassName()); } public static string GetClassName(this object value) { return value.GetClassName(); } } ...

php array returns undefined but print_r shows otherwise [duplicate]

This question already has an answer here: PHP: “Notice: Undefined variable” and “Notice: Undefined index” 11 answers foreach($jsonmediationinfo as $value1) { echo $value1['mstatus']; print_r($jsonmediationinfo); } Output: 1Array ( [0] => Array ( [mstatus] => 1 [mhearingnum] => first [mminutes] => adakjaflafjlarjkelfkalfkd;la ) [1] => Array ( [mhearingnum] => second...

Practical Reasons to use C# “named arguments”

I find this feature "named arguments" from C# to be really weird because I see two flaws from it. The book says "named arguments give you the "ability to pass arguments in any order". Two flaws I think is a problem for this C# feature: It violates "information hiding" in...

setting objects equal to eachother (java)

So I have a class called Person which looks like this public class Person { private String personName; public String toString(){ return personName; } public Person(String personName){ this.personName = personName; } } and another class in which I am creating the object(s) person public class IdanJavaTask { public static void...

Object Oriented Python - rectangle using classes and functions

I am creating a program in Python that will utilize object oriented programming to print the properties of a given rectangle. The project has these given constraints: The purpose of this lab is to give you practice creating your own object. You will be given a main function that expects...

Basic CakePHP: Edit Post Method become Add Post Method

Currently following the blog tutorial however my database and their variable are different. I was looking through the "Edit Post" method and follow the step they given however they turn into "Add Post" method. What is the reason that cause it ? (I have set the hidden field at view...

Method nonvisibility of same instanceof but differing class

I have something like the below: Item var; Depending on user input, it will be initialized as a different class: if (/*user input*/ == 1) { var = new Item(); } else { var = new Truck(); } The classes are defined as: public class Truck extends Item { public...