Search Results

Search found 2842 results on 114 pages for 'undefined hero'.

Page 21/114 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Linker error when compiling boost.asio example

    - by Alon
    Hi, I'm trying to learn a little bit C++ and Boost.Asio. I'm trying to compile the following code example: #include <iostream> #include <boost/array.hpp> #include <boost/asio.hpp> using boost::asio::ip::tcp; int main(int argc, char* argv[]) { try { if (argc != 2) { std::cerr << "Usage: client <host>" << std::endl; return 1; } boost::asio::io_service io_service; tcp::resolver resolver(io_service); tcp::resolver::query query(argv[1], "daytime"); tcp::resolver::iterator endpoint_iterator = resolver.resolve(query); tcp::resolver::iterator end; tcp::socket socket(io_service); boost::system::error_code error = boost::asio::error::host_not_found; while (error && endpoint_iterator != end) { socket.close(); socket.connect(*endpoint_iterator++, error); } if (error) throw boost::system::system_error(error); for (;;) { boost::array<char, 128> buf; boost::system::error_code error; size_t len = socket.read_some(boost::asio::buffer(buf), error); if (error == boost::asio::error::eof) break; // Connection closed cleanly by peer. else if (error) throw boost::system::system_error(error); // Some other error. std::cout.write(buf.data(), len); } } catch (std::exception& e) { std::cerr << e.what() << std::endl; } return 0; } With the following command line: g++ -I /usr/local/boost_1_42_0 a.cpp and it throws an unclear error: /tmp/ccCv9ZJA.o: In function `__static_initialization_and_destruction_0(int, int)': a.cpp:(.text+0x654): undefined reference to `boost::system::get_system_category()' a.cpp:(.text+0x65e): undefined reference to `boost::system::get_generic_category()' a.cpp:(.text+0x668): undefined reference to `boost::system::get_generic_category()' a.cpp:(.text+0x672): undefined reference to `boost::system::get_generic_category()' a.cpp:(.text+0x67c): undefined reference to `boost::system::get_system_category()' /tmp/ccCv9ZJA.o: In function `boost::system::error_code::error_code()': a.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x10): undefined reference to `boost::system::get_system_category()' /tmp/ccCv9ZJA.o: In function `boost::asio::error::get_system_category()': a.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x7): undefined reference to `boost::system::get_system_category()' /tmp/ccCv9ZJA.o: In function `boost::asio::detail::posix_thread::~posix_thread()': a.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x1d): undefined reference to `pthread_detach' /tmp/ccCv9ZJA.o: In function `boost::asio::detail::posix_thread::join()': a.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[boost::asio::detail::posix_thread::join()]+0x25): undefined reference to `pthread_join' /tmp/ccCv9ZJA.o: In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service<boost::asio::detail::epoll_reactor<false> > >::context>::~posix_tss_ptr()': a.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEED2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEED5Ev]+0xf): undefined reference to `pthread_key_delete' /tmp/ccCv9ZJA.o: In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service<boost::asio::detail::epoll_reactor<false> > >::context>::posix_tss_ptr()': a.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEEC2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEEC5Ev]+0x22): undefined reference to `pthread_key_create' collect2: ld returned 1 exit status How can I fix it? Thank you.

    Read the article

  • XMLNodes being appended to an XMLNode are "undefined"? Actionscript 2.0 is being unkind

    - by DigitalMercenary
    If anyone can offer an explanation for this one, I'd LOVE to see it! I was required to append a legacy application to display 20 random questions from an XML data source, as opposed to the total of 70 questions that are part of the original XML. No big deal, right? WRONG! I got it to work just fine in the end, but it's a total HACK! For some reason, some of the nodes that I am appending to a dynamically generated XML document are being returned as "undefined". I kept getting between 16 and 20 questions to render until I modified my iteration from a 'for' loop to a 'do while' loop with the appropriate number of XMLNodes as the condition of the 'do while' loop. Can anyone offer an explanation? Below is the code, with some notes for the reader : function editXML(xml:XML):XML { var node:XMLNode = xml.firstChild; var newNode:XMLNode = new XMLNode(); var nodeArray:Array = new Array(); var usedNodes:Array = new Array(); var totalNodes:Number = node.lastChild.childNodes.length - 1; var nextNode:Number; var returnNode:XMLNode = new XMLNode(); var tempNode:XMLNode; var buildNode:XMLNode; var addNode:Boolean = true; var tempXML:XML = new XML(); var pagesNode:XMLNode = tempXML.createElement("pages"); tempXML.appendChild(pagesNode); tempXML.appendChild(node.childNodes[0]); tempXML.appendChild(node.childNodes[1]); tempXML.appendChild(node.childNodes[2]); var questionsNode:XMLNode = tempXML.createElement("pages"); tempXML.firstChild.appendChild(questionsNode); do { nextNode = Math.floor(Math.random()*totalNodes); **//random number to represent random node** //trace(nextNode + " nextNode"); **//check usedNodes Array to look for node.childNodes[nextNode]. If it already exists, skip and reloop.** trace(node.childNodes[1].childNodes[nextNode] + " : pre building Node " + totalNodes); if(usedNodes.length == 0) { buildNode = new XMLNode(); buildNode.nodeName = node.childNodes[1].childNodes[nextNode].nodeName; buildNode.nodeValue = node.childNodes[1].childNodes[nextNode].nodeValue; tempXML.firstChild.lastChild.appendChild(node.childNodes[1].childNodes[nextNode]) usedNodes.push(node.childNodes[1].childNodes[nextNode]); nodeArray.push(node.childNodes[1].childNodes[nextNode]); trace("adding first node : " + nodeArray.length); addNode = false; } else { for(var j:Number = 0; j < usedNodes.length; j++) { if(usedNodes[j] == node.childNodes[1].childNodes[nextNode]) { addNode = false; trace("skipping node : " + nodeArray.length); } } } **//if node not in usedNodes, add node to XML** if(addNode) { trace(node.childNodes[1].childNodes[nextNode] + " : building Node"); **//This trace statement produced a valid node** tempXML.firstChild.lastChild.appendChild(node.childNodes[1].childNodes[nextNode]); **//Before modifying the code from adding nodes to the xml from an Array called 'nodeArray' in a for loop to adding nodes directly to the xml in a do while loop with the length of the xml node used to retrieve data for the questions as the condition, I was not always getting 20 questions. Some of the nodes were being rendered as 'undefined' and not appended to the xml, even though they were traced and proven valid before the attemp to append them to the xml was made** usedNodes.push(node.childNodes[1].childNodes[nextNode]); } addNode = true; } while(tempXML.firstChild.lastChild.childNodes.length <= 19); trace(tempXML.firstChild.lastChild.childNodes.length + " final nodes Length"); courseXML = tempXML; //removes the old question list of 70 and replaces it with the new question list of 20. Question list is the last node. return tempXML; } If I had my choice, I would have rebuilt the whole application in Flex with AS3. I didn't have that choice. If anyone can explain this mystery, PLEASE DO! Thank you in advance!

    Read the article

  • Where am I going wrong? "undefined method 'application' for Sinatra:Module" Sinatra/Passenger/Apache

    - by safetycopy
    Hi, I'm trying to get my first Sinatra app off the ground, but am getting an error page from Passenger: undefined method `application' for Sinatra:Module Here's my Rackup file: require 'rubygems' require 'sinatra' set :env, :production disable :run require 'app' run Sinatra.application And the app itself: #!/usr/bin/env ruby require 'rubygems' require 'sinatra' require 'haml' get '/' do haml :index end get '/hello/:name' do |name| @name = name haml :hello end get '/goodbye/:name' do |name| haml :goodbye, :locals => {:name => name} end __END__ @@layout %html %head %title hello.dev %body =yield @@index #header %h1 hello.dev #content %p This is a test... @@hello %h1= "Hello #{@name}!" @@goodbye %h1= "Goodbye #{name}!" Where am I going wrong?

    Read the article

  • Converting kernel image from ELF to PE

    - by Frank Miller
    I am using Msys to build a home brew kernel that I wrote under Linux. Linux used ELF for its binary format and Msys uses PE. I have the source setup to allow it to be booted by Grub using the Multiboot spec. At the end of the build, I get some undefined symbols: init.o:init.S:(.text+0x14): undefined reference to `edata' main.o:main.c:(.text+0x121): undefined reference to `_alloca' main.o:main.c:(.text+0x126): undefined reference to `__main' ../../lib\libkern.a(mem.o):mem.c:(.text+0x242): undefined reference to `_end' ../../lib\libkern.a(mem.o):mem.c:(.text+0x323): undefined reference to `_end' These appear to be ELF oriented symbols. If anyone can advise me on how these should be dealt with in the PE world, e.g. if there are equivalents, it would help me out a lot!

    Read the article

  • Why am I getting the error "undefined local variable or method `assigns'"?

    - by Jason
    I might be missing something basic here, but I'm stumped on this error: model code: class CachedStat < ActiveRecord::Base def self.create_stats_days_ago(days_ago, human_id) d = Date.today - days_ago.day @prs = PageRequest.find(:all, :conditions => [ "owner_type = 'Human' and owner_id = ? and created_at = ?", human_id, d] ) end end spec code: it "should create stats for the specified number of days in the past" do CachedStat.create_stats_days_ago(1, Human.first.id) assigns[:prs].should eql("foo") end The error is: undefined local variable or method `assigns' for #<Spec::Rails::Example::ModelExampleGroup::Subclass_1:0x2fbac28> I feel like I'm overlooking something obvious but it's invisible to me. Any suggestions? Thanks very much! -Jason

    Read the article

  • How to disable a warning in Delphi about "return value ... might be undefined"?

    - by Lasse V. Karlsen
    I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035 Return value of function 'function' might be undefined The function, however, is clean, small, and does have a known, expected, return value. The first statement in the function is: Result := ''; and there is no local variable or parameter called Result either. Is there any kind of pragma-like directive I can surround this method with to remove this warning? This is Delphi 2007. Unfortunately, the help system on this Delphi installation is shot, so I can't pop up the help for that warning right now. Anyone know off the top of their head what I can do?

    Read the article

  • is_admin? function in rails? - undefined method Error

    - by Newbie
    Hello! At the moment, I am creating some kind of admin panel/backend for my site. I want to do the following: Only admins (a user has a user_role(integer) -- 1 = admin, 2 = moderator, 3 = user) can see and access a link for the admin panel. So I created an admin_controller. In my admin controller I created a new function called is_admin?: class AdminController < ApplicationController def admin_panel end def is_admin? current_user.user_role == 1 end end my route looks like. map.admin_panel '/admin-panel', :controller => 'admin', :action => 'admin_panel' and in my _sidebar.html.erb (partial in applicaton.html.erb) I created the link: <%= link_to "Admin Panel", :admin_panel unless is_admin? %> Now I get an error called: undefined method `is_admin?' Where is the problem? Please help me solving this problem!

    Read the article

  • TypeError: Result of expression 'printWindow' [undefined] is not an object.

    - by orangebrainer
    I'm trying to create hidden iframes in my page dynamically to load 3 other pages so that i can grab all the HTML and combine them into 1 in a new window. However i'm stuck at this. tHe frames are created fine. But whenever the javascript runs to the part of function openNewWindow() { var printWindow = window.open("",""); printWindow.document.open(); printWindow.document.write(HTMLfromFrames); printWindow.document.close(); } i get this error: TypeError: Result of expression 'printWindow' [undefined] is not an object. but if i generate a button to call this function seperately, it works fine. however i need it to run all in one click event Anybody has any idea what's wrong? Thanks!

    Read the article

  • used structdelete and now Elementemployee.id is undefined in SESSION.

    - by Robert
    using coldfuion 9 I used structdelete(session,"Elementemployee.id") in one of my .cfm display files.Also in my application.cfc it defined as is <cfset tArray[1][2] = "#session.employee_id#"> and the error is `Elementemployee.id is undefined in SESSION.` Is there a way that i can reset it without following the method shown below Navigate to the page Server Settings => Memory Variablesin the Coldfusion Administrator. Uncheck the option Use J2EE session variables and check the options Enable Application Variables and Enable Session Variables. Click the button to submit the changes.

    Read the article

  • ypeError: Result of expression 'printWindow' [undefined] is not an object.

    - by orangebrainer
    I'm trying to create hidden iframes in my page dynamically to load 3 other pages so that i can grab all the HTML and combine them into 1 in a new window. However i'm stuck at this. tHe frames are created fine. But whenever the javascript runs to the part of openNewWindow(); { var printWindow = window.open("",""); printWindow.document.open(); printWindow.document.write(HTMLfromFrames); printWindow.document.close(); } i get this error: TypeError: Result of expression 'printWindow' [undefined] is not an object. but if i generate a button to call this function seperately, it works fine. however i need it to run all in one click event Anybody as any idea what's wrong? Thanks!

    Read the article

  • javascript error : periodLookup[periodStr] is undefined, why is it throwing this error?

    - by Mo
    Hi i have this method: set_period_help_text: function(periodInput){ var metric = MonitorMetric.getSelectedMetric(); var periodStr = $('select[name=metric_period]').val(); var datapoints = Number(periodInput.attr("value")); var period = datapoints * periodLookup[periodStr][0]; } var periodLookup = { "OneMinute": [1, "minute"], "FiveMinute": [5, "minute"], "OneHour": [1, "hour"], "OneDay": [1, "day"], "OneWeek": [1, "week"] }; where var periodStr is being retrived from a dropdown menue that only has the values: "OneMinute" "FiveMinute" "OneHour" "OneDay" "OneWeek" i get a java script error when the page loads: periodLookup[periodStr] is undefined [Break on this error] var period = datapoints * periodLookup[periodStr][0];

    Read the article

  • Are unspecified and undefined behavior required to be consistent between compiles?

    - by sharptooth
    Let's pretend my program contains a specific construct the C++ Standard states to be unspecified behavior. This basically means the implementation has to do something reasonable but is allowed not to document it. But is the implementation required to produce the same behavior every time it compiles a specific construct with unspecified behavior or is it allowed to produce different behavior in different compiles? What about undefined behavior? Let's pretend my program contains a construct that is UB according to the Standard. The implementation is allowed to exhibit any behavior. But can this behavior differ between compiles of the same program on the same compiler with same settings in the same environment? In other words, if I dereference a null pointer on line 78 in file X.cpp and the implementation formats the drive in such case does it mean that it will do the same after the program is recompiled?

    Read the article

  • Ensure house map maze with lifts can be solved?

    - by Philipp Lenssen
    In my game we see the floors of a house from the side, and the hero can take lifts -- a lift either goes up (to the next lift upwards), or down (to the next lift downwards), depending on the arrow as shown, and there's always a pair of exactly two lifts connected. That's the only way the hero can move vertically, though he can freely move horizontally. The house map is a randomized 11x5 grid with different items, and unpassable walls to the far left, far right, and sometimes in one of the two middle positions: My question: How can I ensure the map is always randomized yet always solvable and that the hero, starting at the left side of the bottom floor, can always leave it via any upwards-pointing lift at the top floor? For what it's worth I'm using the Lua language for development. Thanks so much!

    Read the article

  • Multiple objects listening for the same key press

    - by xiaohouzi79
    I want to learn the best way to implement this: I have a hero and an enemy on the screen. Say the hero presses "k" to get out a knife, I want the enemy to react in a certain way. Now, if in my game loop I have a listener for the key press event and I identify a "k" was pressed, the quick and easy way would be to do: // If K pressed // hero.getOoutKnife() // enemy.getAngry() But what is commonly done in more complex games, where say I have 10 types of character on screen and they all need to react in a unique way when the letter "k" is pressed? I can think of a bunch of hacky ways to do this, but would love to know how it should be done properly. I am using C++, but I'm not looking for a code implementation, just some ideas on how it should be done the right way.

    Read the article

  • jquery use return data from 2 functions in another function ---always get undefined. why ??

    - by user253530
    Function socialbookmarksTableData(data) is called by another function to generate the content of a table -- data is a JSON object. Inside the function i call 2 other functions that use getJSON and POST (with json as a return object) to get some data. The problem is: though the functions execute correctly i get undefined value for the 2 variables (bookmarkingSites, bookmarkCategories). Help with a solution please. function socialbookmarksGetBookmarkCategories(bookmarkID) { var toReturn = ''; $.post("php/socialbookmark-get-bookmark-categories.php",{ bookmarkID: bookmarkID },function(data){ $.each(data,function(i,categID){ toReturn += '<option value ="' + data[i].categID + '">' + data[i].categName + '</option>'; }) return toReturn; },"JSON"); } function socialbookmarksGetBookmarkSites() { var bookmarkingSites = ''; $.getJSON("php/socialbookmark-get-bookmarking-sites.php",function(bookmarks){ for(var i = 0; i < bookmarks.length; i++){ //alert( bookmarks[i].id); bookmarkingSites += '<option value = "' + bookmarks[i].id + '">' + bookmarks[i].title + '</option>'; } return bookmarkingSites; }); } function socialbookmarksTableData(data) { var toAppend = ''; var bookmarkingSites = socialbookmarksGetBookmarkSites(); $.each(data.results, function(i, id){ var bookmarkCategories = socialbookmarksGetBookmarkCategories(data.results[i].bookmarkID); //rest of the code is not important }); $("#searchTable tbody").append(toAppend); }

    Read the article

  • undefined method `content_type' for nil:NilClass /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2

    - by Y Kamesh Rao
    Strange error in diagnostics.erb file about _set_controller_content_type. Please help. NoMethodError in Timelines#public_timeline Showing /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/templates/rescues/diagnostics.erb where line # raised: undefined method `content_type' for nil:NilClass Extracted source (around line #): RAILS_ROOT: /Volumes/DATA/Source/Rails/tvider Application Trace | Framework Trace | Full Trace /opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/whiny_nil.rb:52:in method_missing' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/base.rb:331:in_set_controller_content_type' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/renderable.rb:32:in block in render' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/base.rb:306:inwith_template' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/renderable.rb:30:in render' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/template.rb:205:inrender_template' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/base.rb:265:in render' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:134:inrescue_action_locally' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:152:in rescue_action_without_handler' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:74:inrescue_action' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:162:in rescue in perform_action_with_rescue' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:inperform_action_with_rescue' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in perform_action_with_flash' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:inprocess' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in process_with_filters' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:inprocess' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in call' /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:incall' Request Parameters: None Show session dump Response Headers: {"Cache-Control"="no-cache", "Content-Type"=""}

    Read the article

  • Why do I get "undefined method `destroy'" when including 'svn/repos'?

    - by Chad Johnson
    I get the following when running script/server require 'svn/repos' script/console Loading development environment (Rails 2.3.5) require 'svn/repos' /Library/Ruby/Site/1.8/svn/core.rb:88: warning: already initialized constant Stream /Library/Ruby/Site/1.8/svn/core.rb:138: warning: already initialized constant AuthBaton NoMethodError: undefined method destroy' for #<Svn::Ext::Core::Apr_pool_wrapper_t:0x10150ae68> from /Library/Ruby/Site/1.8/svn/util.rb:60:insvn_fs_initialize' from /Library/Ruby/Site/1.8/svn/util.rb:60:in call' from /Library/Ruby/Site/1.8/svn/util.rb:60:ininitialize' from /Library/Ruby/Site/1.8/svn/fs.rb:14 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:innew_constants_in' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' from /Library/Ruby/Site/1.8/svn/repos.rb:5 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in new_constants_in' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire' from (irb):1 Any idea why?

    Read the article

  • Undefined method `add' on a cucumber step that usually works.

    - by Josiah Kiehl
    I have a path defined: when /the admin home\s?page/ "/admin/" I have scenario that is passing: Scenario: Let admins see the admin homepage Given "pojo" is logged in And "pojo" is an "admin" And I am on the admin home page Then I should see "Hi there." And I have a scenario that is failing: Scenario: Review flagged photo Given "pojo" is logged in And "pojo" is an "admin" ...bunch of steps that create stuff in the database... And I am on the admin home page Then ... the rest of the steps The step that fails in the second one is "And I am on the admin home page" which passes just fine in the first scenario. Here's the error I get: And I am on the admin home page # features/step_definitions/web_steps.rb:18 undefined method `add' for {}:Hash (NoMethodError) ./app/controllers/admin_controller.rb:13:in `index' ./app/controllers/admin_controller.rb:11:in `each' ./app/controllers/admin_controller.rb:11:in `index' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' ./features/step_definitions/web_steps.rb:19:in `/^(?:|I )am on (.+)$/' features/admin.feature:52:in `And I am on the admin home page' This is very odd... why would it be fine in the first case, and not in the second where the only difference are a bunch of steps that create records in the db? [edit] Here's the add stuff to database step: Given /^there is a "([^\"]*)" with the following:$/ do |model, table| model.constantize.create!(table.rows_hash) end

    Read the article

  • backbone.js Model.get() returns undefined, scope using coffeescript + coffee toaster?

    - by benipsen
    I'm writing an app using coffeescript with coffee toaster (an awesome NPM module for stitching) that builds my app.js file. Lots of my application classes and templates require info about the current user so I have an instance of class User (extends Backbone.Model) stored as a property of my main Application class (extends Backbone.Router). As part of the initialization routine I grab the user from the server (which takes care of authentication, roles, account switching etc.). Here's that coffeescript: @user = new models.User @user.fetch() console.log(@user) console.log(@user.get('email')) The first logging statement outputs the correct Backbone.Model attributes object in the console just as it should: User _changing: false _escapedAttributes: Object _pending: Object _previousAttributes: Object _silent: Object attributes: Object account: Object created_on: "1983-12-13 00:00:00" email: "[email protected]" icon: "0" id: "1" last_login: "2012-06-07 02:31:38" name: "Ben Ipsen" roles: Object __proto__: Object changed: Object cid: "c0" id: "1" __proto__: ctor app.js:228 However, the second returns undefined despite the model attributes clearly being there in the console when logged. And just to make things even more interesting, typing "window.app.user.get('email')" into the console manually returns the expected value of "[email protected]"... ? Just for reference, here's how the initialize method compiles into my app.js file: Application.prototype.initialize = function() { var isMobile; isMobile = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/); this.helpers = new views.DOMHelpers().initialize().setup_viewport(isMobile); this.user = new models.User(); this.user.fetch(); console.log(this.user); console.log(this.user.get('email')); return this; }; I initialize the Application controller in my static HTML like so: jQuery(document).ready(function(){ window.app = new controllers.Application(); }); Suggestions please and thank you!

    Read the article

  • undefined method `key?' for nil:NilClass when using MongoMapper

    - by Radek Slupik
    I set up a new Rails application by following these instructions. I generated a new controller and added resources :tickets to the routes file. Hexapoda::Application.routes.draw do resources :tickets end This is the controller (`/app/controllers/tickets_controller.rb'). class TicketsController < ApplicationController def index @tickets = Ticket.all end end I then added a new model Ticket in /app/models/ticket.rb. class Ticket include MongoMapper::Document key :summary, String, :required => true end Here's the view (/app/views/index.html.erb): <h1>Tickets#index</h1> <p>Find me in app/views/tickets/index.html.erb</p> Now when I go to /tickets in my browser, I get an error message. NoMethodError in TicketsController#index undefined method `key?' for nil:NilClass I have no idea what's going on. What could be the problem? I'm using Rails 3.2.5 and MongoMapper 0.11.1.

    Read the article

  • Can a PHP object respond to an undefined method?

    - by Nathan Long
    Rails relies on some of the neat aspects of Ruby. One of those is the ability to respond to an undefined method. Consider a relationship between Dog and Owner. Owner has_many :dogs and Dog belongs_to :owner. If you go into script/console, get a dog object with fido = Dog.find(1), and look at that object, you won't see a method or attribute called Owner. What you will see is an owner_id. And if you ask for fido.owner, the object will do something like this (at least, this is how it appears to me): I'm being asked for my .owner attribute. I don't have one of those! Before I throw a NoMethodError, do I have a rule about how to deal with this? Yes, I do: I should check and see if I have an owner_id. I do! OK, then I'll do a join and return that owner object. PHP's documentation is - ahem - a bit lacking sometimes, so I wonder if anyone here knows the answer to this: Can I define similar behavior for objects in PHP? If not, do you know of a workaround for flexible model joins like these?

    Read the article

  • Can't call an object method. PHP reports variable undefined

    - by user1285697
    This is the weirdest bug! It is probably something silly, but I have no idea how to fix it. If anyone could help, I would be most grateful! I have three files, one is called items.php, another is called tableFunctions.php, and the third is called mysql.php. I use two global objects called 'mysql' and 'tableFunctions'. They are stored in the files 'mysql.php', and 'tableFunctions.php', respectively. In each file, I create an instance of its object, assigning it to the global variable $_mysql, or $_table. like this: In the file mysql.php: global $_mysql; $_mysql = new mysql(); In the file tableFunctions.php: global $_table; $_table = new tableFunctions(); Here's how it is supposed to work: The items.php file includes the tableFunctions.php file... Which in turn, needs the mysql.php file, so it includes it too. In the items.php file, I call the method getTable(), which is contained in the object tableFunctions.(and in the variable $_table.) Like this: $t = $_table->getTable('items'); The getTable function calls the method, arrayFromResult(), which is contained within in the object mysql.(and in the variable $_mysql.) Like this: $result = $_mysql->arrayFromResult($r); That's where I get the error. PHP says that the variable '$_mysql' is undefined, but I defined it in the 'mysql.php' file.(see above) I also included mysql.php with the following code: include_once 'mysql.php'; I have no idea what is wrong! If anyone can help that would be much appreciated. The source files can be downloaded with the following link: https://www.dropbox.com/sh/bjj2gyjsybym89r/YLxqyNvQdn

    Read the article

  • Why am I getting 'undefined method' exceptions when executing 'run_list add', 'run_list remove' and 'rackspace server delete'?

    - by Peter Groves
    [Originally posted this to opscode forum, got no response] I’m testing out a free hosted chef-server account and multiple subcommands are failing with ‘Unexpected Errors’. Perhaps my version and the server version are incompatible? OS: Ubuntu 12.04LTS Local Chef: 10.12.0 (Installed through gem) Local Ruby: 1.8.7 Also, the workstation machine has been manually configured, but the client(s) I’ve been experimenting with are launched with the Rackspace plugin (using ‘knife rackspace server create…’) The problem commands seem to fail when talking to the host chef-server, however, before it ever tries to modify the client, so I don’t believe that’s where the problem exists. The virtual-servers that are launched by ‘knife rackspace server create’ are launched properly but then deleting them with knife fails. If I include a recipe in the run_list when I create the server, the recipe is properly added to the run_list. If I try to add it later or remove the one that there server was initialized with, those commands fail. Here is the output of a few relevant commands (with stacktraces): https://gist.github.com/7100ada3fd6690113697

    Read the article

  • Google Analytics recording event based on <a> title attribute

    - by rlsaj
    I am declaring: var title = (typeof(el.attr('title')) != 'undefined' ) ? el.attr('title') :""; and then have the following: else if (title.match(/^"Matching Content"\:/i)) { elEv.category = "Matching Content Click"; elEv.action = "click-Matching-Content"; elEv.label = href.replace(/^https?\:\/\//i, ''); elEv.non_i = true; elEv.loc = href; } However, using Google Analytics debugger this is not being recorded. Any suggestions? The complete function is: if (typeof jQuery != 'undefined') { jQuery(document).ready(function gLinkTracking($) { var filetypes = /\.(avi|csv|dat|dmg|doc.*|exe|flv|gif|jpg|mov|mp3|mp4|msi|pdf|png|ppt.*|rar|swf|txt|wav|wma|wmv|xls.*|zip)$/i; var baseHref = ''; if (jQuery('base').attr('href') != undefined) baseHref = jQuery('base').attr('href'); jQuery('a').on('click', function (event) { var el = jQuery(this); var track = true; var href = (typeof(el.attr('href')) != 'undefined' ) ? el.attr('href') :""; var title = (typeof(el.attr('title')) != 'undefined' ) ? el.attr('title') :""; var isThisDomain = href.match(document.domain.split('.').reverse()[1] + '.' + document.domain.split('.').reverse()[0]); if (!href.match(/^javascript:/i)) { var elEv = []; elEv.value=0, elEv.non_i=false; if (href.match(/^mailto\:/i)) { elEv.category = "Email link"; elEv.action = "click-email"; elEv.label = href.replace(/^mailto\:/i, ''); elEv.loc = href; } else if (title.match(/^"Matching Content"\:/i)) { elEv.category = "Matching Content Click"; elEv.action = "click-Matching-Content"; elEv.label = href.replace(/^https?\:\/\//i, ''); elEv.non_i = true; elEv.loc = href; } else if (href.match(filetypes)) { var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined; elEv.category = "File Downloaded"; elEv.action = "click-" + extension[0]; elEv.label = href.replace(/ /g,"-"); elEv.loc = baseHref + href; } else if (href.match(/^https?\:/i) && !isThisDomain) { elEv.category = "External link"; elEv.action = "click-external"; elEv.label = href.replace(/^https?\:\/\//i, ''); elEv.non_i = true; elEv.loc = href; } else if (href.match(/^tel\:/i)) { elEv.category = "Telephone link"; elEv.action = "click-telephone"; elEv.label = href.replace(/^tel\:/i, ''); elEv.loc = href; } else track = false; if (track) { _gaq.push(['_trackEvent', elEv.category.toLowerCase(), elEv.action.toLowerCase(), elEv.label.toLowerCase(), elEv.value, elEv.non_i]); if ( el.attr('target') == undefined || el.attr('target').toLowerCase() != '_blank') { setTimeout(function() { location.href = elEv.loc; }, 400); return false; } } } }); }); }

    Read the article

  • Authlogic openid: getting undefined method openid_identifier? error in functional test

    - by usr
    I use Authlogic with the Authlogic-openid addon (I gem installed ruby- openid and script/plugin install git://github.com/rails/open_id_authentication.git) and get two errors. First when running functional test, I get an undefined method openid_identifier? message on a line in my new.html.erb file when running the UsersControllerTest. The line is: <% if @user.openid_identifier? %> When running script/console I can access this method without any problem. Second when testing the openid functionality and registering a new user to my application using openid and using my blogspot account for that I get the following in my log file: Generated checkid_setup request to http://www.blogger.com/openid-server.g with assocication ... Redirected to http://www.blogger.com/openid-server.g?openid.assoc_handle=... NoMethodError (You have a nil object when you didn't expect it! The error occurred while evaluating nil.call): app/controllers/users_controller.rb:44:in `create' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/lib/ruby/1.8/webrick/server.rb:92:in `each' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' The code in the users_controller is straight forward: def create respond_to do |format| @user.save do |result| if result flash[:notice] = t('Thanks for signing up!') format.html { redirect_to :action => 'index' } format.xml { render :xml => @user, :status => :created, :location => @user } else format.html { render :action => "new" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end end The line giving the error being @user.save do |result|... I feel I'm missing something pretty basic but I have been staring at this for too long because I can't find what it is. I checked with the code on Railscasts episodes 160 and 170 and the bones GitHub project but found nothing. Thanks for your help, usr

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >