Search Results

Search found 572 results on 23 pages for 'christian stadegaart'.

Page 15/23 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Help with active record relations

    - by Christian Fazzini
    class CreateActivities < ActiveRecord::Migration def self.up create_table :activities do |t| t.references :user t.references :media t.integer :artist_id t.string :type t.timestamps end end def self.down drop_table :activities end end class Fan < Activity belongs_to :user, :counter_cache => true end class Activity < ActiveRecord::Base belongs_to :user belongs_to :media belongs_to :artist, :class_name => 'User', :foreign_key => 'artist_id' end class User < ActiveRecord::Base has_many :activities has_many :fans end I tried changing my activity model too, without any success: class Activity < ActiveRecord::Base has_many :activities, :class_name => 'User', :foreign_key => 'user_id' has_many :activities, :class_name => 'User', :foreign_key => 'artist_id' end One thing to note. Activity is an STI. Fan inherits from Activity. In console, I do: # Create a fan object. User is a fan of himself fan = Fan.new => #<Fan id: nil, user_id: nil, media_id: nil, artist_id: nil, type: "Fan", comment: nil, created_at: nil, updated_at: nil> # Assign a user object fan.user = User.first => #<User id: 1, genre_id: 1, country_id: 1, .... # Assign an artist object fan.artist_id = User.first.id => 1 # Save the fan object fan.save! => true Activity.last => #<Fan id: 13, user_id: 1, media_id: nil, artist_id: 1, type: "Fan", comment: nil, created_at: "2010-12-30 08:41:25", updated_at: "2010-12-30 08:41:25"> Activity.last.user => #<User id: 1, genre_id: 1, country_id: 1, ..... But... Activity.last.artist => nil Why is Activity.last.artist returning nil?

    Read the article

  • Shared static classes between AppDomains in loaded library code

    - by Christian Stewart
    I'm working on a program in which I want to do something similar to what the Photon Server system does: Offer a common "API" class library, which contains common data classes, enumerations, and interfaces for working with the host program. Have client programs (class libraries) reference this DLL and implement interfaces listed within it. Have the "host" application load built DLL client libraries into separate AppDomains and reference the interfaces that lie within to have polymorphic client code from within a dll file. I have something like this worked out: a class library that contains common code, but I've run into the following question How should I handle static classes? Should I add a method that is called by the host program to synchronize data? How do I keep a static class the same between AppDomains? Should I discard these classes in favor of better interfaces between the code levels? And in general, how do I share data between these loaded AppDomains?

    Read the article

  • How can I control my winmo phone?

    - by Christian W
    I have been trying to find a way to control my winmo phone from my pc. (HTC S740) What I want is to be able to call a number from an application, answer the phone from an application and hangup the phone from an application. It should also be able to track how long the ongoing call has been. Any libraries out there that lets me make such an application with C#? (The phone is connected to the pc via usb in Windows 7.)

    Read the article

  • Ubuntu 8.04 LTS MySQL port remote access

    - by Stig Christian
    Hi! I have tried everything I know, but still no solution to this problem. MySQL works perfectly on localhost, but it seems port 3306 is blocked from the outside... I have commented out "bind-address" in /etc/mysql/my.cnf, and there is no iptables rules that deny this port. (I have even opened the port in iptables just to be sure) Still I can`t connect to the server from a remote connection (telnet or portscan returns negative results). Where is the problem?

    Read the article

  • opening and viewing a file in php

    - by Christian Burgos
    how do i open/view for editing an uploaded file in php? i have tried this but it doesn't open the file. $my_file = 'file.txt'; $handle = fopen($my_file, 'r'); $data = fread($handle,filesize($my_file)); i've also tried this but it wont work. $my_file = 'file.txt'; $handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); $data = 'This is the data'; fwrite($handle, $data); what i have in mind is like when you want to view an uploaded resume,documents or any other ms office files like .docx,.xls,.pptx and be able to edit them, save and close the said file. edit: latest tried code... <?php // Connects to your Database include "configdb.php"; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM employees") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data //Echo "<img src=localhost/uploadfile/images".$info['photo'] ."> <br>"; Echo "<b>Name:</b> ".$info['name'] . "<br> "; Echo "<b>Email:</b> ".$info['email'] . " <br>"; Echo "<b>Phone:</b> ".$info['phone'] . " <hr>"; //$file=fopen("uploadfile/images/".$info['photo'],"r+"); $file=fopen("Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/file.odt","r") or exit("unable to open file");; } ?> i am getting the error: Warning: fopen(Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/file.odt): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/uploadfile/view.php on line 17 unable to open file the file is in that folder, i don't know it wont find it.

    Read the article

  • How can I fade in a JPanel & children?

    - by Christian 'fuzi' Orgler
    I know that I can fade in a panel, by adding the alpha value to the background color & a timer. But how can I fade in a panel with child components (like a JLabel)? EDIT _fadeTimer = new Timer(40, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (_alpha == 255) { _fadeTimer.stop(); } else { pnl_hint.setBackground(new Color( bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), (_alpha += 1))); pnl_hint.updateUI(); } } }); _fadeTimer.start();

    Read the article

  • Regular Expression issue

    - by Christian Sciberras
    I have the following URL structure which I need to match to and get the particular id from: /group/subgroup/id-name In short, I need to translate a URL like the following: /Blue Products/Dark Blue/5-Blue_Jelly To: /?pagename=Blue Products&model=5 IMPORTANT: I don't need to match group, I already have group. Example code: <?php foreach($cats as $cat) $cmd->rewrite('/\/'.$cat.'\/unused\/(ID)-unused\//','/?pagename='.$cat.'&model=%ID%'); ?> Edit: This is the completed code: if($groups->count()){ $names=array(); foreach($groups->rows as $row) $names[]=preg_quote($row->group); $names=implode('|',$names); $regex='('.$names.')/([^/]+)/([0-9]{1,})-([^/]+)/?$'; CmsHost::cms()->rewrite_url($regex,'index.php?pagename=Products',true); }

    Read the article

  • Laravel - Mail class Exception

    - by Christian Giupponi
    I need to send email within my app and this is my code: if( $agent->save() ) { //Preparo la mail da inviare con i dati di login $data = [ 'nome' => $input['nome'], 'cognome' => $input['cognome'], 'email' => $input['email'], 'password' => $input['password'] ]; //ATTENZIONE //Questo è da rimuovere in produzione, finge di inviare la mail Mail::pretend(); //Recuero il template e passo alla funzione i dati Mail::send('emails.agents.registration', $data, function($message) use ($data) { $message->to( $data['email'], $data['nome'].' '.$data['cognome'] )->subject('Benvenuto!'); }); return Redirect::action('admin.agents.index')->with('positive_flash_message', 'Agente inserito correttamente.'); } As you can see I have use the Mail::pretend to avoid the email send in development, the problem is that I get this error every time I try to send an email: Undefined property: Illuminate\Mail\Message::$email (View: /var/www/progetti/app/views/emails/agents/registration.blade.php) nd this is my blade view: Email: {{ $message->email }} Password: {{ $message->password }} What's wrong with $message?

    Read the article

  • Pull news from an RDF Feed using Ruby and Nokogiri?

    - by Christian
    I would like to pull the titleand description fields from the newsfeed at http://www.tagesschau.de/newsticker.rdf to feed them to the Mac's Text-to-Speech engine. My search for a nice Ruby Gem to do this has brought me to Nokogiri, but all examples that "pull something out" of a given XML seem to be centered around CSS somehow. Does anyone have any idea how to save the titleand description fields in an array?

    Read the article

  • MYSQL, Subquery Reference in Union

    - by christian
    Is there any way to reference a subquery in a union? I am trying to do something like the following, and would like to avoid a temporary table, but the subquery will be drawn from a much larger dataset so it makes sense to only do it once.. SELECT * FROM (SELECT * FROM ads WHERE state='FL' AND city='Maitland' AND page='home' ORDER BY RAND()) AS sq WHERE spot = 'full-banner' LIMIT 1 UNION SELECT * FROM sq WHERE spot = 'leaderboard' LIMIT 1 UNION SELECT * FROM sq WHERE spot = 'rectangle1' LIMIT 1 UNION SELECT * FROM sq WHERE spot = 'rectangle2' LIMIT 1 .... etc,, It's a shame that DISTINCT can't be specified for a single column of a result set.

    Read the article

  • Allowed characters in linux environment variable names

    - by Christian Semrau
    What characters are allowed in linux environment variable names? My cursory search of man pages and the web did only produce information about how to work with variables, but not which names are allowed. I have a Java program that requires an defined environment variable containing a dot, like com.example.fancyproperty. With Windows I can set that variable, but I had no luck setting it in linux (tried in SuSE and Ubuntu). Is that variable name even allowed?

    Read the article

  • In LaTeX, is there a way to get long lines along the margins?

    - by Christian Jonassen
    I'm working on a report, and some elements are outside the margins (but some are just barely outside the margins). I was wondering: Is there a way to make two vertical lines, one on each side, along the margins so that one can easily see if it goes outside them? (Googling it, I only found information about margin notes.) A figure is below: |report text goes here| |more text goes also h|ere |and so on and so fort|h It would certainly make correcting these kinds of mistakes very trivial. :) Feel free to post answers that would solve/show this problem in a more "LaTeX-correct" way, if that makes any sense at all.

    Read the article

  • Free java or flash file browser for photogallery

    - by Christian
    Hi. I'm about to develop a small web gallery, where it's supposed to be possible to upload several pictures at a time and then add some info abut the pictures.So I need a free java or flash local file browser that can pass me some info of the pictures that gets uploaded so that I can create some SQL entries for each picture. The platform for the project will be PHP and MySQL. Any good recommendations?

    Read the article

  • Why is Routes.rb not loading the IPs from cache?

    - by Christian Fazzini
    I am testing this in local. My ip is 127.0.0.1. The ip_permissions table, is empty. When I browse the site, everything works as expected. Now, I want to simulate browsing the site with a banned IP. So I add the IP into the ip_permissions table via: IpPermission.create!(:ip => '127.0.0.1', :note => 'foobar', :category => 'blacklist') In Rails console, I clear the cache via; Rails.cache.clear. I browse the site. I don't get sent to pages#blacklist. If I restart the server. And browse the site, then I get sent to pages#blacklist. Why do I need to restart the server every time the ip_permissions table is updated? Shouldn't it fetch it based on cache? Routes look like: class BlacklistConstraint def initialize @blacklist = IpPermission.blacklist end def matches?(request) @blacklist.map { |b| b.ip }.include? request.remote_ip end end Foobar::Application.routes.draw do match '/(*path)' => 'pages#blacklist', :constraints => BlacklistConstraint.new .... end My model looks like: class IpPermission < ActiveRecord::Base validates_presence_of :ip, :note, :category validates_uniqueness_of :ip, :scope => [:category] validates :category, :inclusion => { :in => ['whitelist', 'blacklist'] } def self.whitelist Rails.cache.fetch('whitelist', :expires_in => 1.month) { self.where(:category => 'whitelist').all } end def self.blacklist Rails.cache.fetch('blacklist', :expires_in => 1.month) { self.where(:category => 'blacklist').all } end end

    Read the article

  • best way to build iphone settings screen

    - by Christian Schlensker
    I'm building a settings screen for an iPhone app and it is supposed to resemble a grouped table view. Each "cell" should behave like a button. Most cells just have a image view, label view, and disclosure indicator. One will display a value in addition to a label. All of these buttons will present a new view when tapped. Now, how to implement this? I was considering just laying out a set of buttons with custom background images, or would it be best to just use a table view. If that's the case what should it be implemented. So far I've only used table views to display some kind of dynamic data in which each cell displayed the same basic detail view. I'm most curious to figure out how to setup cellForRowAtIndexPath. Would this contain some sort of switch statement to configure each cell individually, or is there an easier way to handle all this?

    Read the article

  • how to swap array-elements to transfer the array from a column-like into a row-like representation

    - by Christian Ammer
    For example: the array a1, a2, a3, b1, b2, b3, c1, c2, c3, d1, d2, d3 represents following table a1, b1, c1, d1 a2, b2, c2, d2 a3, b3, c3, d3 now i like to bring the array into following form a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3 Does an algorithm exist, which takes the array (from the first form) and the dimensions of the table as input arguments and which transfers the array into the second form? I thougt of an algorithm which doesn't need to allocate additional memory, instead i think it should be possible to do the job with element-swap operations.

    Read the article

  • Is it possible to establish default values for inherited fields in subclasses?

    - by Christian Mann
    I'm trying to establish a default value for inherited fields from superclasses. So, my class hierarchy is thus: Character - Enemy - Boss                 \                   - Hero Each Character has a public static char avatar to represent him on an ASCII playing field. How do I set a default value for the avatar of each class inherited from Character? Thank you!

    Read the article

  • Jquery passing an HTML element into a function

    - by christian
    I have an HTML form where I am going to copy values from a series of input fields to some spans/headings as the user populates the input fields. I am able to get this working using the following code: $('#source').keyup(function(){ if($("#source").val().length == 0){ $("#destinationTitle").text('Sample Title'); }else{ $("#destinationTitle").text($("#source").val()); } }); In the above scenario the html is something like: Sample Title Basically, as the users fills out the source box, the text of the is changed to the value of the source input. If nothing is input in, or the user deletes the values typed into the box some default text is placed in the instead. Pretty straightforward. However, since I need to make this work for many different fields, it makes sense to turn this into a generic function and then bind that function to each 's onkeyup() event. But I am having some trouble with this. My implementation: function doStuff(source,target,defaultValue) { if($(source).val().length == 0){ $(target).text(defaultValue); }else{ $(target).text($(source).val()); } } which is called as follows: $('#source').keyup(function() { doStuff(this, '"#destinationTitle"', 'SampleTitle'); }); What I can't figure out is how to pass the second parameter, the name of the destination html element into the function. I have no problem passing in the element I'm binding to via "this", but can't figure out the destination element syntax. Any help would be appreciated - many thanks!

    Read the article

  • Using FieldSelector when searching with Lucene

    - by Christian
    I'm searching articles in PubMed via Lucene. Each of the 20,000,000 articles has an abstract with ~250 words and an ID. At the moment I store my searches, with each take multiple seconds, in a TopDocs object. Searchs can find thousands of articles. I'm just interested in the ID of the article. Does Lucene load the abstracts internally into the TopDocs? If so can I prevent that behavior through FieldSelectors or do FieldSelectors only work with IndexReader and don't work with IndexSearcher?

    Read the article

  • Magento order status change events

    - by Christian
    Hi people, I want to change via web service a remote inventory, I know that via Event Observer Method can triger my code, but I don't know which event is useful to complete my task, like on_order_complete, is there an updated list of events or more documentation?

    Read the article

  • Using TDD: "top down" vs. "bottom up"

    - by Christian Mustica
    Since I'm a TDD newbie, I'm currently developing a tiny C# console application in order to practice (because practice makes perfect, right?). I started by making a simple sketchup of how the application could be organized (class-wise) and started developing all domain classes that I could identify, one by one (test first, of course). In the end, the classes have to be integrated together in order to make the application runnable, i.e. placing necessary code in the Main method which calls the necessary logic. However, I don't see how I can do this last integration step in a "test first" manner. I suppose I wouldn't be having these issues had I used a "top down" approach. The question is: how would I do that? Should I have started by testing the Main() method? If anyone could give me some pointers, it will be much appreciated.

    Read the article

  • Compare filedate before download it

    - by Christian
    Hi, I have an app which is downloading several plist-files when starting the app and storing them in the NSHomeDirectory/Documents/ path. This will take some time and often there is only one file that changed. My questions are: -how can I get the date of the files (the stored one and the file on my webserver)? -how can I compare the date of the stored file with the date of the file on my webserver?

    Read the article

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