Daily Archives

Articles indexed Wednesday April 21 2010

Page 13/126 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Ruby on Rails: how to get error messages from a child resource displayed?

    - by randombits
    I'm having a difficult time understanding how to get Rails to show explicitly the error messages that a child resource is failing on when I render an XML template. Hypothetically, I have the following classes: class School < ActiveRecord::Base has_many :students validates_associated :students end class Student < ActiveRecord::Base belongs_to :school validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "You must supply a valid email" end Now, in the controller, let's say we want to build a trivial API to allow us to add a new School with a student in it (again, I said, it's a terrible example, but plays its role for the purpose of the question) class SchoolsController < ApplicationController def create @school = School.new @student = school.students.build @student.email = "bad@email" respond_to do |format| if @school.save # some code else format.xml { render :xml => @school.errors, :status => :unprocessable_entity } end end end end Now the validation is working just fine, things die because the email doesn't match the regex that's set in the validates_format_of method in the Student class. However the output I get is the following: <?xml version="1.0" encoding="UTF-8"?> <errors> <error>Students is invalid</error> </errors> I want the more meaningful error message that I set above with validates_format_of to show up. Meaning, I want it to say: <error>You must supply a valid email</error> What am I doing wrong for that not to show up?

    Read the article

  • Stop browser throbber spinning for Comet using iframe

    - by Shanison
    When I use comet using iframe push, the browser throbber will keep spinning forever while the data is being pushed through the iframe. Lightstreamer is also using iframe, but how do they manage to make it stop? I found a similar post here but it doesn't seem to solve my problem. Any explanation on how lightstreamer works would greatly appreciately. Thank you.

    Read the article

  • Detect URL and Download content from it

    - by Veejay
    I have a page 'PageA' that has around 20 links on it. Each link leads to a different page. How can I access all the links on PageA programmatically and then download each of the pages(20) as .mht? Also is there any existing app that does that?

    Read the article

  • How to eliminate duplicate rows?

    - by Odette
    hi guys im back with my original query and i just have one question please (ps: I know i have to vote and regsiter and I promise I will do that today) With the following query (t-sql) I am getting the correct results, except that there are duplicates now. I have been reading up and think I can use the PARTITION BY syntax - can you please show me how to incorporate the PARTITION BY syntax? WITH CALC1 AS (SELECT OTQUOT, OTIT01 AS ITEMS, ROUND(OQCQ01 * OVRC01,2) AS COST FROM @[email protected] WHERE OTIT01 < '' UNION ALL ... SELECT OTQUOT, OTIT10 AS ITEMS, ROUND(OQCQ10 * OVRC10,2) AS COST FROM @[email protected] WHERE OTIT10 < '' ) SELECT OTQUOT, DESC, ITEMS, RN FROM ( SELECT OTQUOT, ITEMS, B.IXRPGP AS GROUP, C.OTRDSC AS DESC, COST, ROW_NUMBER() OVER (PARTITION BY OTQUOT ORDER BY COST DESC) AS RN FROM CALC1 AS A INNER JOIN @[email protected] AS B ON (A.ITEMS = B.IKITMC) INNER JOIN DATAGRP.GDSGRP AS C ON (B.IXRPGP = C.OKRPGP) ) T RESULTS: 60408169 FENCING GNCPDCTP18BGBG 1 60408169 FENCING CGIFESHPD1795BG 2 60408169 FENCING GTTCGIBG 3 60408169 FENCING GBTCGIBG 4 How do I get rid of the duplicates? thanks Bill and all the others for your help (I am still learning!)

    Read the article

  • UIbutton stretchable

    - by mindfreak
    I have 2 images for UIbutton (1 for normal state and 1 for highlited state). When the button is highlited the height of button increases(as per image size) . I want that height of button should increase only from top and not from bottom. I mean it should stretch from top .is it possible ? if yes ,how ?

    Read the article

  • C++ wxWidgets Event Handling

    - by Wallter
    Q1:I am using wxWidgets (C++) and have come accost a problem that i can not locate any help. I have created several wxTextCtrl boxes and would like the program to update the simple calculations in them when the user 'kills the focus.' I could not find any documentation on this subject on the wxWidgets webpage and Googling it only brought up wxPython. The two events i have found are: EVT_COMMAND_KILL_FOCUS - EVT_KILL_FOCUS for neither of which I could find any snippet for. Could anyone give me a short example or lead me to a page that would be helpful? Q2:Would i have to create an event to handle the focus being killed for each of my 8 wxTextCtrl boxes? In the case that i have to create a different event: How would i get each event to differentiate from each other? I know i will have to create new wxID's for each of the wxTextCtrl boxes but how do I get the correct one to be triggered? class BasicPanel : public wxPanel { ... wxTextCtrl* one; wxTextCtrl* two; wxTextCtrl* three; wxTextCtrl* four; ... }

    Read the article

  • Looking for good PHP editor or IDE with 'IntelliSense'

    - by Andrew
    Hello, I'm looking for suitable PHP Editor or IDE with syntax auto-completion. I've tried trial versions of programs like Zend Studio, PHPDesigner, NetBeans PHP, NuSphere PhpED, and similar -- but none of them fully satisfied me. I quite liked hint window with detailed info about what function does and what it returns. Also I liked the way NetBeans auto-complete code (for example inserts all required parameters in function declaration as "dummy fields" and then you can jump between them using TAB in order to edit them). On the other hand, environment of NetBeans doesn't belong to the nicest. In this regard I prefer PHPDesigner with its sleek and light interface. At this moment I don't use any of the debugging options, since I don't know yet how to use profiller, breakpoints, watches and what not, so at this point my only concern is good autocompletion. For this purpose NetBean would be great choice, but with future in mind I am not sure debugging will be good in NetBeans, especially as I would prefer to use remote Linux server for this. So in short, I'm looking for editor that: Have similar code auto-completion (IntelliSense) like NetBeans Allow you to debug code using remote server (or sets up own debugging server like PHPDesigner does) without need to run Apache and similar on local computer Is preferably easy to use / intuitive interface Any ideas?

    Read the article

  • proxy refused to connect

    - by kichu
    i cant access internet,after showing the message "connection is established" in ubuntu 9.04 version OS . saying that proxy server is refusing to connect.what is the problem?

    Read the article

  • I cannot access Windows Update at all

    - by Cardinal fang
    I have been unable to access the Windows update site for a couple of weeks now. I just get a message saying "Internet Explorer cannot display the webpage" and saying I have connection problems. Same thing is replicated with any other Microsoft site I try to access. The Automatic Updates also do not work. I can access every other wesbite I've surfed to. I've tried Googling the problem and based on what other site have suggested I have cleared my cache and temp files. I've scanning my hard drive with my antivirus in case I have a virus (nada). I've tried turning off my firewall and anti-virus (I run Zone Alarm). I've downloaded SpyBot and scanned my drive with that in case something was missed by Zone Alarm (again nada). Based on suggestions from the smart cookies on the Bad Science forum, I've used nslookup to check my translation isn't wonky (got all the info they said I should get). I've also tried navigating there directly using the IP address I was given (nope). I normally access the internet through a 3 mobile broadband connection, but have also tried connecting using a mate's wi-fi connection in case it was something on my mobile modem interferring. I run Windows XP SP3 with Internet Explorer 7 and Zone Alarm Internet Security Suite as my anti-virus/ firewall. Any suggestions?

    Read the article

  • FTP client that supports 2 concurrent FTP sessions

    - by oninea
    I'm looking for an FTP client that can connect to two different FTP servers at the same time and allow file transfer or synchronization between those two servers. Basically what I want to achieve is to transfer/synchronize files between 2 different sites from my local machine. Are there any clients around that support this functionality? If there are none, is there an alternative to achieve this? I've taken a look at net2ftp, a web based FTP client, which provides almost the same functionality that I need. What I'm looking for though is a desktop app. Any ideas?

    Read the article

  • Due Date set via EWS is wrong in reminder popup

    - by Paul McLean
    I'm having some trouble using EWS with tasks and reminders, specifically, the due date. When I run my code, shown below, the task is added to my exchange account and I can see it fine in outlook. All the data in it looks fine too. However, if I specify to have a reminder for the task, the due date it shows is very wrong. It's usually 17 hours in the future, but the screenshot I've provided shows it being 19 hours in the future. I'm finding it very strange that if I open the task, the due date looks fine, but the reminder is saying it is due well into the future. Any ideas? Screenshot: http://s970.photobucket.com/albums/ae187/paulehn/?action=view&current=ewstask.jpg ExchangeVersion exchVersion = new ExchangeVersion(); exchVersion = ExchangeVersion.Exchange2007_SP1; ExchangeService service = new ExchangeService(exchVersion); service.UseDefaultCredentials = true; service.Url = new Uri("https://mail.domain.com.au/ews/exchange.asmx"); Task task = new Task(service); task.Subject = "Subject"; task.Body = new MessageBody(BodyType.HTML, "Body"); task.StartDate = DateTime.Today; task.DueDate = DateTime.Now.AddHours(2); task.ReminderDueBy = DateTime.Now; task.ReminderMinutesBeforeStart = 15; task.IsReminderSet = true; task.Save();

    Read the article

  • Ordering by multiple columns in mysql with subquery

    - by Scarface
    Hey guys I have a query that selects data and organizes but not in the correct order. What I want to do is select all the comments for a user in that week and sort it by each topic, then sort the cluster by the latest timestamp of each comment in their respective cluster. My current query selects the right data, but in seemingly random order. Does anyone have any ideas? select * from ( SELECT topic.topic_title, topic.topic_id FROM comments JOIN topic ON topic.topic_id=comments.topic_id WHERE comments.user='$user' AND comments.timestamp>$week order by comments.timestamp desc) derived_table group by topic_id

    Read the article

  • Swig - wrapping C struct

    - by user289637
    Hello everyone, I am trying to write Python wrap for C code which uses struct. modules.c: struct foo { int a; }; struct foo bar; modulues.i %module nepal %{ struct foo { int a; } %} extern struct foo bar; But during compiling I am given error: In function ‘Swig_var_bar_set’: error: ‘bar’ undeclared (first use in this function) Could you be so kind to help me how to correctly define export struct variable ?

    Read the article

  • What is the best euphemism for a non-developer?

    - by Edward Tanguay
    I'm writing a description for a piece of software that targets the user who is "not technically minded", i.e. a person who uses "browser/office/email" and has a low tolerance for anything technical, he just "wants it to work" without being involved in any of the technical details. What is the best non-disparaging term you have seen to describe this kind of user? non-technical user low-tech user office user normal user technically challenged user non-developer computer joe Surely there is some official, politically-correct retronym for this kind of user that the press and software marketing use.

    Read the article

  • SSMS Results to Grid - CRLF not preserved in copy/paste - any better techniques?

    - by Cade Roux
    When I have a result set in the grid like: SELECT 'line 1 line 2 line 3' or SELECT 'line 1' + CHAR(13) + CHAR(10) + 'line 2' + CHAR(13) + CHAR(10) + 'line 3' With embedded CRLF, the display in the grid appears to replace them with spaces (I guess so that they will display all the data). The problem is that if I am code-generating a script, I cannot simply cut and paste this. I have to convert the code to open a cursor and print the relevant columns so that I can copy and paste them from the text results. Is there any simpler workaround to preserve the CRLF in a copy/paste operation from the results grid? The reason that the grid is helpful is that I am currently generating a number of scripts for the same object in different columns - a bcp out in one column, an xml format file in another, a table create script in another, etc...

    Read the article

  • TreeMap randomly stops properly returning values

    - by smessing
    I have the following TreeMap: TreeMap<String, Integer> distances = new TreeMap<String, Integer>(); and it contains both strings, "Face" and "Foo", with appropriate values, such that: System.out.println(distances); Yields: {Face=12, Foo=2} However, distances.get(Face) returns null, even though distances.get(Foo) properly returns 2. Previously, distances.get(Face) worked, but for some reason, it stopped working. Note I print out the map right before calling get() for both keys, so I haven't accidentally changed Face's value to null. Has anyone else ever encountered this problem? Is there anything I can do? I'm having a terrible time simply trying to figure out how to debug this problem.

    Read the article

  • How would I go about sharing variables in a C++ class with Lua?

    - by Nicholas Flynt
    I'm fairly new to Lua, I've been working on trying to implement Lua scripting for logic in a Game Engine I'm putting together. I've had no trouble so far getting Lua up and running through the engine, and I'm able to call Lua functions from C and C functions from Lua. The way the engine works now, each Object class contains a set of variables that the engine can quickly iterate over to draw or process for physics. While game objects all need to access and manipulate these variables in order for the Game Engine itself to see any changes, they are free to create their own variables, a Lua is exceedingly flexible about this so I don't forsee any issues. Anyway, currently the Game Engine side of things are sitting in C land, and I really want them to stay there for performance reasons. So in an ideal world, when spawning a new game object, I'd need to be able to give Lua read/write access to this standard set of variables as part of the Lua object's base class, which its game logic could then proceed to run wild with. So far, I'm keeping two separate tables of objects in place-- Lua spawns a new game object which adds itself to a numerically indexed global table of objects, and then proceeds to call a C++ function, which creates a new GameObject class and registers the Lua index (an int) with the class. So far so good, C++ functions can now see the Lua object and easily perform operations or call functions in Lua land using dostring. What I need to do now is take the C++ variables, part of the GameObject class, and expose them to Lua, and this is where google is failing me. I've encountered a very nice method here which details the process using tags, but I've read that this method is deprecated in favor of metatables. What is the ideal way to accomplish this? Is it worth the hassle of learning how to pass class definitions around using libBind or some equivalent method, or is there a simple way I can just register each variable (once, at spawn time) with the global lua object? What's the "current" best way to do this, as of Lua 5.1.4?

    Read the article

  • Windows Designer host, Control.Parent is not correct

    - by nils_gate
    In my Windows Designer host implementation, The top Control's Control.Controls does have all the child controls but for Child control's Control.Parent is set to {System.Windows.Forms.Design.DesignerFrame+OverlayControl} Am I doing something wrong? How to find who is the actual parent of the control while in design mode?

    Read the article

  • Wordpress Shortcode in Theme, Trying to use Gallery

    - by Akash Kava
    We are using SuperSlidShow Plugin to display gallery of images in our post. However when I write shortcode [gallery] in my post/page images appear correctly, but can anyone guide me if I want to fix this [gallery] shortcode in the theme itself like page.php/post.php so that images will appear on all pages. We have images for every page/post.

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >