Search Results

Search found 547 results on 22 pages for 'william jens'.

Page 10/22 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Problems with validates_inclusion_of, acts_as_tree and rspec

    - by Jens Fahnenbruck
    I have problems to get rspec running properly to test validates_inclusion_of my migration looks like this: class CreateCategories < ActiveRecord::Migration def self.up create_table :categories do |t| t.string :name t.integer :parent_id t.timestamps end end def self.down drop_table :categories end end my model looks like this: class Category < ActiveRecord::Base acts_as_tree validates_presence_of :name validates_uniqueness_of :name validates_inclusion_of :parent_id, :in => Category.all.map(&:id), :unless => Proc.new { |c| c.parent_id.blank? } end my factories: Factory.define :category do |c| c.name "Category One" end Factory.define :category_2, :class => Category do |c| c.name "Category Two" end my model spec looks like this: require 'spec_helper' describe Category do before(:each) do @valid_attributes = { :name => "Category" } end it "should create a new instance given valid attributes" do Category.create!(@valid_attributes) end it "should have a name and it shouldn't be empty" do c = Category.new :name => nil c.should be_invalid c.name = "" c.should be_invalid end it "should not create a duplicate names" do Category.create!(@valid_attributes) Category.new(@valid_attributes).should be_invalid end it "should not save with invalid parent" do parent = Factory(:category) child = Category.new @valid_attributes child.parent_id = parent.id + 100 child.should be_invalid end it "should save with valid parent" do child = Factory.build(:category_2) child.parent = Factory(:category) # FIXME: make it pass, it works on cosole, but I don't know why the test is failing child.should be_valid end end I get the following error: 'Category should save with valid parent' FAILED Expected #<Category id: nil, name: "Category Two", parent_id: 5, created_at: nil, updated_at: nil to be valid, but it was not Errors: Parent is missing On console everything seems to be fine and work as expected: c1 = Category.new :name => "Parent Category" c1.valid? #=> true c1.save #=> true c1.id #=> 1 c2 = Category.new :name => "Child Category" c2.valid? #=> true c2.parent_id = 100 c2.valid? #=> false c2.parent_id = 1 c2.valid? #=> true I'm running rails 2.3.5, rspec 1.3.0 and rspec-rails 1.3.2 Anybody, any idea?

    Read the article

  • How can I determine img width/height of dynamically loaded images in IE?

    - by Jens
    My markup is a simple div element with id 'load'. Using jQuery I then load a list of image elements into this div: $('#load').load('images.html', { }, function() { $(this).onImagesLoad({ selectorCallback: function() { ....do something.... } }); }); where images.html is a list like this: <img src='1.jpg' caption='img 1'> <img src='2.jpg' caption='img 2'> ... To ensure that all images are loaded completely, I use the onImagesLoad plugin. This, so far, works just fine on all browsers. However, on IE8 (and I assume other versions of IE also) when I then iterate over the img elements, I am unable to determine the width/height of the images loaded. The image.context.naturalWidth and naturalHeight attributes don't seem to work. How do I get a hold of the images' dimension? Thanks heaps :)

    Read the article

  • Unable to display google maps in a dojo layout

    - by Jens
    Dear All, I am a real newbie in programming and now I have to combine Google Maps and Dojo. Both alone are fine but when I try to implement a Google Map into a Dojo content pane which is embedded in a border-container it simply does not work. I think there is a problem with the naming of the divs but perhaps there is something else to take care of? Could someone post the simplest possible solution? many thanks

    Read the article

  • Hibernate: fetching multiple bags efficiently

    - by Jens Jansson
    Hi! I'm developing a multilingual application. For this reason many objects have in their name and description fields collections of something I call LocalizedStrings instead of plain strings. Every LocalizedString is basically a pair of a locale and a string localized to that locale. Let's take an example an entity, let's say a book -object. public class Book{ @OneToMany private List<LocalizedString> names; @OneToMany private List<LocalizedString> description; //and so on... } When a user asks for a list of books, it does a query to get all the books, fetches the name and description of every book in the locale the user has selected to run the app in, and displays it back to the user. This works but it is a major performance issue. For the moment hibernate makes one query to fetch all the books, and after that it goes through every single object and asks hibernate for the localized strings for that specific object, resulting in a "n+1 select problem". Fetching a list of 50 entities produces about 6000 rows of sql commands in my server log. I tried making the collections eager but that lead me to the "cannot simultaneously fetch multiple bags"-issue. Then I tried setting the fetch strategy on the collections to subselect, hoping that it would do one query for all books, and after that do one query that fetches all LocalizedStrings for all the books. Subselects didn't work in this case how i would have hoped and it basically just did exactly the same as my first case. I'm starting to run out of ideas on how to optimize this. So in short, what fetching strategy alternatives are there when you are fetching a collection and every element in that collection has one or multiple collections in itself, which has to be fetch simultaneously.

    Read the article

  • VB.net Network Graph code/algorithm

    - by Jens
    For a school project we need to visualise a computer network graph. The number of computers with specific properties are read from an XML file, and then a graph should be created. Ad random computers are added and removed. Is there any open source project or algorithm that could help us visualising this in VB.net? Or would you suggest us to switch to java. Update: We eventually switched java and used the Jung libraries because this was easier for us to understand and implement.

    Read the article

  • JSDoc3: How to document a AMD module that returns a function

    - by Jens Simon
    I'm trying to find a way to document AMD modules using JSDoc3. /** * Module description. * * @module path/to/module */ define(['jquery', 'underscore'], function (jQuery, _) { /** * @param {string} foo Foo-Description * @param {object} bar Bar-Description */ return function (foo, bar) { // insert code here }; }); Sadly none of the patterns listed on http://usejsdoc.org/howto-commonjs-modules.html work for me. How can I generate a proper documentation that lists the parameters and return value of the function exported by the module?

    Read the article

  • CSS - Overlapping divs

    - by Jens Törnell
    I have no code to start with. I want to add 2 divs overlapping on each other and then use the new CSS3 Rotate function. The effect I want to create is shown on this page Requirements I don't want to use images I don't mind using CSS3 It should be easy to align the whole thing in the center (which makes it harder to use position: absolute;). It's going to be content below the boxed content (which makes it harder to use position: absolute;). If it's possible without too much position: absolute; it's better. I prefer table free solutions. Have fun!

    Read the article

  • Is there a way to clear all JavaScript timers at once?

    - by Jens
    Im building an automatic refreshing comment section for my website using jQuery .load. So I am using a javascript 'setTimeout' timer to check for new comments. But after doing some stuff like changing comment pages or deleting (all using ajax), a few old timers keep running, even though I used clearTimeout before loading new ajax content. Is there some way to clear ALL javascript timers when I load new ajax content?

    Read the article

  • Default Sorting in DynamicData

    - by Jens A.
    I am using DynamicData in the version that shipped with VS2008. In the default List view, the data is sorted by order of entry into the database. I'd like to get it sorted by a field of a specific name (descending). As a last resort I tried to use the OrderByParameter of the LinqDataSource with a QueryStringParameter, but I could not get it to sort anything. =) Is there an easy way to accomplish this?

    Read the article

  • Performance problems when loading local JSON via <script> elements in IE8

    - by Jens Bannmann
    I have a web page with some JS scripts that needs to work locally, e.g. from hard disk or a CD-ROM. The scripts load JSON data from files by inserting <script> tags. This worked fine in IE6, but now in IE8 it takes an enormous amount of time: it went from "instantly" to 3-10 seconds. The main data file is 45KB large. How can I solve this? I would switch from <script> tags to another method of loading JSON (ideally involving the new native JSON parser), but it seems locally loaded content cannot access the XMLHttpRequest object. Any ideas?

    Read the article

  • Image expire time

    - by Jens
    The google page speed tool recommends me to set 'Expires' headers for images etc. But what is the most efficient way to set an Expires header for an image? In now redirect all image requests to an imagehandler.php using htaccess: /* HTTP/1.1 404 Not Found, HTTP/1.1 400 Bad Request and content type detection stuff ... */ header( "Content-Type: " . $content_type ); header( "Cache-Control: public" ); header( "Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime($path))." GMT"); header( "Expires: ". date("r",time() + (60*60*24*30))); readfile( $path ); But of course this adds extra loading time for my images on first request, and I was wondering if there was a better solution for this.

    Read the article

  • PHP find array keys

    - by Jens Törnell
    In PHP I have an array that looks like this: $array[0]['width'] = '100'; $array[0]['height'] = '200'; $array[2]['width'] = '150'; $array[2]['height'] = '250'; I don't know how many items there are in the array. Some items can be deleted which explains the missing [1] key. I want to add a new item after this, like this: $array[]['width'] = '300'; $array[]['height'] = '500'; However the code above don't work, because it adds a new key for each row. It should be the same for the two rows above. A clever way to solve it? An alternative solution would be to find the last key. I failed trying the 'end' function.

    Read the article

  • Tiling rectangles seamlessly in WPF while maintaing subpixel accuracy?

    - by Jens
    I have had the problem described in the question Tiling rectangles seamlessly in WPF, but am not really happy with the answers given there. I am painting a bar chart by painting lots of rectangles right next to each other. Depending on the scale of the canvas containing them, there are small gaps visible between some of them as a result from sub-pixel rendering. I learned from the above question how to make my rectangles fit with the screen pixels, removing that effect. Unfortunately, my chart may display way more bars than there are pixels. Apart from the tiny gaps (which manifest as a periodic change in color saturation), this works well. If I snap each bar with the screen pixels, most of the bars vanish, though, so I am looking for another solution. Thanks in advance!

    Read the article

  • Mysql optimization

    - by Jens
    I have this mysql table called comments which looks like this: commentID parentID type userID date comment The commentID is set as Primary key, but most of the time I fetch the data using the parentID. How should I set my indexes? Should I just add an index on parentID and let commentID be the primary key?

    Read the article

  • Java Instance of: Supertypes and Subtypes seem to be equal? How to test exactly for Type?

    - by jens
    I need to test, if an instance is exactly of a given type. But it seems that instanceof returns true also if the subtype is tested for the supertype (case 3). I never knew this before and I am quite surprised. Am I doing something wrong here? How do I exactly test for a given type? //.. class DataSourceEmailAttachment extends EmailAttachment //... EmailAttachment emailAttachment = new EmailAttachment(); DataSourceEmailAttachment emailAttachmentDS = new DataSourceEmailAttachment(); if (emailAttachment instanceof EmailAttachment){ System.out.println(" 1"); } if (emailAttachment instanceof DataSourceEmailAttachment){ System.out.println(" 2"); } if (emailAttachmentDS instanceof EmailAttachment){ System.out.println(" 3 "); } if (emailAttachmentDS instanceof DataSourceEmailAttachment){ System.out.println(" 4"); } RESULT: 1 3 4 I want to avoid case 3, I only want "exact matches" (case 1 and 4) how do I test for them?

    Read the article

  • Working with version control on a Drupal/CMS project

    - by Jens Ljungblad
    I was wondering how teams that develop sites using Drupal (or any other CMS) integrate version control, subversion, git or similar, into their workflow. You'd obviously want your custom code and theme files under version control but when you use a CMS such as Drupal a lot of the work consists of configuring modules and settings all of which is stored in the database. So when you are a team of developers, how do you collaborate on a project like this? Dumping the database into a file and putting that file under version control might work I guess, but when the site is live the client is constantly adding content which makes syncing a bit problematic. I'd love to know how others are doing this.

    Read the article

  • ASP.NET DynamicData: Whats happening during an update?

    - by Jens A.
    I am using ASP.NET DynamicData (based on LINQ to SQL) on my site for basic scaffolding. On one table I have added additional properties, that are not stored in the table, but are retrieved from somewhere else. (Profile information for a user account, in this case). They are displayed just fine, but when editing these values and pressing "Update", they are not changed. Here's what the properties look like, the table is the standard aspnet_Users table: public String Address { get { UserProfile profile = UserProfile.GetUserProfile(UserName); return profile.Address; } set { UserProfile profile = UserProfile.GetUserProfile(UserName); profile.Address = value; profile.Save(); } } When I fired up the debugger, I've noticed that for each update the set accessor is called three times. Once with the new value, but on a newly created instance of user, then once with the old value, again on an new instance, and finally with the old value on the existing instance. Wondering a bit, I checked with the properties created by the designer, and they, too, are called three times in (almost) the same fashion. The only difference is, that the last call contains the new value for the property. I am a bit stumped here. Why three times, and why are my new properties behaving differently? I'd be grateful for any help on that matter! =)

    Read the article

  • Which relational databases exist with a public API for a high level language?

    - by Jens Schauder
    We typically interface with a RDBMS through SQL. I.e. we create a sql string and send it to the server through JDBC or ODBC or something similar. Are there any RDBMS that allow direct interfacing with the database engine through some API in Java, C#, C or similar? I would expect an API that allows constructs like this (in some arbitrary pseudo code): Iterator iter = engine.getIndex("myIndex").getReferencesForValue("23"); for (Reference ref: iter){ Row row = engine.getTable("mytable").getRow(ref); } I guess something like this is hidden somewhere in (and available from) open source databases, but I am looking for something that is officially supported as a public API, so one finds at least a note in the release notes, when it changes. In order to make this a question that actually has a 'best' answer: I prefer languages in the order given above and I will prefer mature APIs over prototypes and research work, although these are welcome as well.

    Read the article

  • Finding existing tickets before opening new ones on trac

    - by Jens Jansson
    We're using Trac as the task management tool at the project we work in. However, Trac search is maybe not the most intuitive search out there, and we end up having multiple duplicates as the reporters can't effectively find if there already is a reported ticket of the question he or she found. Stack Overflow's "Related Questions" concept is great and works magnificently! I was wondering if someone has heard of some similar plugin to Trac, or if you have solved this problem some other way.

    Read the article

  • Why should I prefer OSGi Services over exported packages?

    - by Jens
    Hi, I am trying to get my head around OSGi Services. The main question I keep asking myself is: What's the benefit of using services instead of working with bundles and their exported packages? As far as I know it seems the concept of Late Binding has something to do with it. Bundle dependencies are wired together at bundle start, so they are pretty fixed I guess. But with services it seems to be almost the same. A bundle starts and registers services or binds to services. Of course services can come and go whenever they want and you have to keep track of these chances. But the core idea doesn't seem that different to me. Another aspect to this seems to be that services are more flexible. There could be many implementations for one specific Interface. On the other hand there can be a lot of different implementations for a specific exported package too. In another text I read that the disadvantage of using exported packages is that they make the application more fragile than services. The author wrote that if you remove one bundle from the dependency graph other dependencies would no longer be met, thus possibly causing a domino effect on the whole graph. But couldn't the same happen if a service would go offline? To me it looks like service dependencies are no better than bundle dependencies. So far I could not find a blog post, book or presentation that could clearly describe why services are better than just exposing functionality by exporting and importing packages. To sum my questions up: What are the key benefits of using OSGi Services that make them superior to exporting and importing packages?

    Read the article

  • links for 2011-03-08

    - by Bob Rhubart
    The Empowered Business "Someone needs to be the enterprise parent that asks the question, “do you really need that?” It may be a shiny new thing, but does it make a difference in the ability to accomplish the strategy and goals?" - Enterprise Architect Todd Biske (tags: enterprisearchitecture) Knowledge Workers in the British Raj "While we’ve used technology to change business, business has also evolved to the point that it’s changing how we think about and use technology." - Peter Evans Greenwood (tags: enterprisearchitecture enterprise2.0) Arun Gupta, Miles to go ...: OTN Developer Day Boston 2011 - Slides & Trip Report Arun Gupta shares slides from his Developer Day presentations. (tags: oracle otn java) Use WLST to Delete All JMS Messages From a Destination (James Bayer's Blog) James Bayer responds to a question. (tags: oracle otn weblogic jms) Triangle Circle Square: Apex in the Amazon Cloud Scott Wesley shares several links to resources covering Oracle Apex on an Amazon EC2 instance. (tags: oracle apex ec2 amazon cloud) William Vambenepe: Reading IBM's proposed standard for Cloud Architecture The always entertaining William Vambenepe gives IBM's proposed Cloud standards the full Ebert. (tags: oracle cloud ibm standards) Government Information Group Cloud Computing Research Study "The twin pressures of reduced budgets and the need for greater efficiency have led the federal government to strongly promote cloud computing as a solution whenever possible." (tags: cloudcomputing cloud) The Ron Batra Blog: Technology Whispers: Top 10 Reasons to go ExaData "Continuing my exploration of ExaData, I thought I'd take a minute to consolidate my thoughts into key reasons for which Oracle ExaData could be a good fit for your needs." - Oracle ACE Director Ron Batra (tags: oracle oracleace exadata) Oracle WebCenter: Composite Applications & Mash-Ups (Oracle Enterprise 2.0 Blog) "The new Business Mash-up editor allows business users to take any Oracle Application or 3rd party application and wire the backend data sources or APIs to a rich set of visualizations and reuse them in mashups." (tags: oracle webcenter enterprise2.0) Antonio Romero: Great Discussion of ETL and ELT Tooling in TDWI Linkedin Group Antonio says: "There’s a great discussion of ETL and ELT tooling going on in the official TDWI Linkedin group, under the heading 'How Sustainable is SQL for ETL?' It delves into a wide range of topics." (tags: oracle linkedin etl elt) YouTube - Bunny Inc. - Episode 1. Mr. CIO meets Mr. Executive Manager Yes, it's a commercial. But it's well done and it's funny. (tags: e20 enterprise2.0 webcenter) Markus Eisele: Both Weblogic and Glassfish are strategic products for Oracle Oracle ACE Director Markus Eisele shares selected quotes pulled from the recent TechCast Live interview with Oracle's Anil Gaur and Adam Leftik (tags: oracle java weblogic glassfish) How to become an Oracle SOA expert? (SOA Partner Community Blog) Jurgan Kress shares info and links for those interested in capitalizing on SOA. (tags: oracle soa)

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >